• Resolved Cjohnson1073

    (@cjohnson1073)


    Hello,

    I am new to WordPress and so far love it. I’m trying to create a site using Tablepress to display information from a table. What I’d like to do is have a single row selected at random displayed each time a user opens or refreshes the page. An example of what I’d like to do is have a table with 30 different workouts of the day and a user would have one displayed at random each day. Is this something that is able to be done using the Tablepress plugin?

    Thank you so much for your help!!

    CJohnson1073

    http://wordpress.org/plugins/tablepress/

Viewing 10 replies - 1 through 10 (of 10 total)
  • Plugin Author TobiasBg

    (@tobiasbg)

    Hi,

    thanks for your question.

    This is possible with a Premium TablePress Extension.
    Please see http://tablepress.org/extensions/table-row-order/ for more information.
    Basically, you would use the “random” function from there, combined with some more parameters to then show only one row in the table:

    [table id=123 row_order="random" table_head="false" hide_rows="all" show_rows="1" /]

    Regards,
    Tobias

    Thread Starter Cjohnson1073

    (@cjohnson1073)

    Tobias,

    Thank you for the reply. I was able to understand what you showed in the coding above but I’m having one problem. At the end of the code where it says show_rows=”1″, it is pulling the first line in the table which is labeled Exercise #1 every time rather than pulling the top line in the randomly organized table. I’ll keep working with it and will definitly send a donation your way once I figure it out. Thanks again.

    CJohnson1073

    Plugin Author TobiasBg

    (@tobiasbg)

    Hi,

    argh, yeah, this method won’t work like this unfortunately, my bad… Basically, right now, the hiding of the other rows is done before the randomization is run, which is why you always only get the first row…
    I’ll try to think of another way and reply again later today.

    Regards,
    Tobias

    Thread Starter Cjohnson1073

    (@cjohnson1073)

    Tobias,

    Rather than trying to figure out a way to select the first row after the table is randomized, is there a way to have the show_rows=” ” command have a randomly picked variable. This way the table doesn’t need to be randomized, just the row number being called. The tables that I’m looking to create would have approximately 30 rows with different information and I would only need to pull one row each time. I’m assuming that I’d have to declare the number of rows in each table before the random number is picked so that it is within the range of the table I’m working with. Thanks for your help!!

    CJohnson1073

    Plugin Author TobiasBg

    (@tobiasbg)

    Hi,

    no, there’s no way to send a random number to show_rows= which is way I came up with the idea of randomizing the table and then grabbing the first row from that 🙂

    But your suggestion is also worth looking into (it might actually be easier to do), so I will try to find a way like that!

    Regards,
    Tobias

    Plugin Author TobiasBg

    (@tobiasbg)

    Hi,

    okay, I think that I have nice solution now 🙂

    Please check out the new TablePress Extension at http://tablepress.org/extensions/random-row/

    Regards,
    Tobias

    Thread Starter Cjohnson1073

    (@cjohnson1073)

    Tobias,

    I have some good news. I installed the plugin as you instructed and created a table with 30 rows to test it. I first used the Chrome browser and the plugin worked fantastically. This was exactly what I was looking for. I then loaded the same page on Firefox, Internet Explorer 8 (I’m on my work computer and still running XP unfortunately) and also tried it using the Chrome browser on my Android phone. Unfortunately the results were not as good. For some reason the row being displayed on the other browsers all get stuck on Row 17. I will try more recent browsers on my home laptop tonight to see if I get the same results. All rows in the table are identical with the exception of the row description in the first column. You can view the page I am working with at: http://laddkarate.net/practicemaster/beginner-workout/ . This is the very early stage of what I have planned once I get the table randomization working. Keep an eye out for a donation coming your way for the work that you have done so far. Confirmation number: 8SE05810BC006940B. I really appreciate your help.

    CJohnson1073

    Edit: I went into the table to double check the entries and then resaved it. Now the tables are getting stuck on other pages in all browsers except Chrome for the desktop.

    Plugin Author TobiasBg

    (@tobiasbg)

    Hi Chris,

    good to hear that the basic randomization works 🙂

    That problem with the row being “stuck” happens because of the WP-SuperCache plugin that you are using. That will cache the page with the randomized table.
    (You are probably logged-in into WordPress in Chrome on the desktop, which is why the cache is not being used there. On all other browsers and mobile, the cached version of the page is used.)

    So, you’ll simply have to exclude the page with the table from WP-SuperCache, so that it is not cached anymore.

    And thanks for the donation, I really appreciate it! 🙂

    Regards,
    Tobias

    Thread Starter Cjohnson1073

    (@cjohnson1073)

    Tobias,

    Thank you so much for your help, it is greatly appreciated!! The WP-SuperCache was the problem and after excluding that page, the table worked fantastically!! Once again, thanks for your help.

    CJohnson1073

    Plugin Author TobiasBg

    (@tobiasbg)

    Hi,

    awesome! Great to hear that this helped, and that the Extension is working now 🙂

    Best wishes,
    Tobias

Viewing 10 replies - 1 through 10 (of 10 total)
  • The topic ‘Display a random row.’ is closed to new replies.