Title: 8 latest rows?
Last modified: March 5, 2021

---

# 8 latest rows?

 *  Resolved [aggk](https://wordpress.org/support/users/aggk/)
 * (@aggk)
 * [5 years, 2 months ago](https://wordpress.org/support/topic/8-latest-rows/)
 * Hi,
 * Is it possible to only show the 8 latest rows (ordered by a date column) from
   a table on a certain page, via shortcode?
    …another page would show the whole
   table (via “default” shortcode)
 * Thanks!

Viewing 15 replies - 1 through 15 (of 17 total)

1 [2](https://wordpress.org/support/topic/8-latest-rows/page/2/?output_format=md)
[→](https://wordpress.org/support/topic/8-latest-rows/page/2/?output_format=md)

 *  Plugin Author [Tobias Bäthge](https://wordpress.org/support/users/tobiasbg/)
 * (@tobiasbg)
 * [5 years, 2 months ago](https://wordpress.org/support/topic/8-latest-rows/#post-14138069)
 * Hi,
 * thanks for your post, and sorry for the trouble.
 * This is a bit tricky, due to the sorting of dates…
    You could instruct the DataTables
   JS library to do an initial sorting on the date column, by adding this to the“
   Custom Commands” text field on the table’s “Edit” screen:
 *     ```
       "order": [ [ 0, "asc" ] ]
       ```
   
 * where 0 would define that the sorting shall happen for the first column (counting
   starts with 0).
 * Then, for the “default” Shortcode, you’d have to use
 *     ```
       [table id=123 datatables_custom_commands="" /]
       ```
   
 * to turn the sorting off there.
    This will however only work after adding this
   line of code to your theme’s “functions.php” file:
 *     ```
       add_filter( 'tablepress_disable_custom_commands_shortcode_parameter', '__return_false' );
       ```
   
 * Regards,
    Tobias
 *  Thread Starter [aggk](https://wordpress.org/support/users/aggk/)
 * (@aggk)
 * [5 years, 2 months ago](https://wordpress.org/support/topic/8-latest-rows/#post-14150245)
 * Thank you, the sorting worked great!
 * Is it possible to only show the 8 latest rows (without pagination)?
    …I guess
   I could simply hide pagination with css but if it’s a table with up to 1000 rows
   would it mean these rows are loaded unneccessary in the background at all?
 * …is there any recommended max limit on how large/how many row and columns should
   be used?
 * Thanks!
 *  Plugin Author [Tobias Bäthge](https://wordpress.org/support/users/tobiasbg/)
 * (@tobiasbg)
 * [5 years, 2 months ago](https://wordpress.org/support/topic/8-latest-rows/#post-14150368)
 * Hi,
 * unfortunately, I don’t know a nice way to achieve this without pagination — if
   the sorting still needs to be done. Can you maybe do the sorting already on the“
   Edit” screen?
 * And no, there’s no such recommendation. It will always depend on the type and
   amount of data, and the server configuration (for speed etc.).
 * Regards,
    Tobias
 *  Thread Starter [aggk](https://wordpress.org/support/users/aggk/)
 * (@aggk)
 * [5 years, 2 months ago](https://wordpress.org/support/topic/8-latest-rows/#post-14150430)
 * Ok, thank you!
 * Would you say that it sounds like a bad idea to only show the 8 latest rows from
   a sorted table with up to 1000 rows (only 4 columns) on my front page.
    (on my
   tests on a staging version it runs very quick)
 * …a separate page will display the whole table paginated 20 rows
 * Thanks!
    /Anders
 *  Plugin Author [Tobias Bäthge](https://wordpress.org/support/users/tobiasbg/)
 * (@tobiasbg)
 * [5 years, 2 months ago](https://wordpress.org/support/topic/8-latest-rows/#post-14150519)
 * Hi,
 * I guess it depends on how big the data amount in the overall table is. Sure, 
   it would be some “waste” to load everything first here, but if it works for you,
   you could do it like that.
 * Do you know where these rows will be in the table (before the sorting)? Always
   near the end or top? Or can they be anywhere?
 * Regards,
    Tobias
 *  Thread Starter [aggk](https://wordpress.org/support/users/aggk/)
 * (@aggk)
 * [5 years, 2 months ago](https://wordpress.org/support/topic/8-latest-rows/#post-14150623)
 * The table will be updated through excel file import where new rows always will
   be added below the “last previous row”…so these rows would always be at the end.
 * Thanks!
 *  Plugin Author [Tobias Bäthge](https://wordpress.org/support/users/tobiasbg/)
 * (@tobiasbg)
 * [5 years, 2 months ago](https://wordpress.org/support/topic/8-latest-rows/#post-14150978)
 * Hi,
 * so actually you don’t to show the _latest_ 8 rows (after some date sorting), 
   but the _last_ 8 rows of the table (because the latest rows will always be added
   at the end)?
 * You could then maybe use the TablePress Row Order Extension from [https://tablepress.org/extensions/table-row-order/](https://tablepress.org/extensions/table-row-order/)
   here. Please install and activate that and then try using this Shortcode on the
   page:
 *     ```
       [table id=123 row_order=reverse hide_rows=all show_rows=1-9 /]
       ```
   
 * (with the correct table ID).
 * Regards,
    Tobias
 *  Thread Starter [aggk](https://wordpress.org/support/users/aggk/)
 * (@aggk)
 * [5 years, 2 months ago](https://wordpress.org/support/topic/8-latest-rows/#post-14151305)
 * Thank you, that’s perfect!
 * I see that I can also choose specific column to sort by.
    Does this mean only
   8 rows are actually queried/loaded if I set pagination to 8? (it doesn’t matter
   if I use a table with 1000 rows)
 * Thanks!
 *  Plugin Author [Tobias Bäthge](https://wordpress.org/support/users/tobiasbg/)
 * (@tobiasbg)
 * [5 years, 2 months ago](https://wordpress.org/support/topic/8-latest-rows/#post-14151316)
 * Hi,
 * yes, but that sorting won’t help here, because it can’t sort dates, unfortunately(
   except if they are in yyyy/mm/dd format).
 * And yes, this solution should mean that only the 8 actual rows are loaded.
 * Regards,
    Tobias
 *  Thread Starter [aggk](https://wordpress.org/support/users/aggk/)
 * (@aggk)
 * [5 years, 2 months ago](https://wordpress.org/support/topic/8-latest-rows/#post-14151810)
 * I think yyyy/mm/dd -format will be possible
 * Thank you for your help!
 *  Plugin Author [Tobias Bäthge](https://wordpress.org/support/users/tobiasbg/)
 * (@tobiasbg)
 * [5 years, 2 months ago](https://wordpress.org/support/topic/8-latest-rows/#post-14152165)
 * Hi,
 * no problem, you are very welcome! 🙂 Good to hear that this helped!
 * Best wishes,
    Tobias
 *  Thread Starter [aggk](https://wordpress.org/support/users/aggk/)
 * (@aggk)
 * [5 years, 2 months ago](https://wordpress.org/support/topic/8-latest-rows/#post-14152228)
 * Hi again,
 * …just one more on this. Is there any way to use the same table on different pages
   but with different settings?
    perhaps through parameters or programmatically:
   Set different pagination numbers and disable javascript functionality on one 
   page?
 * Thanks!
 *  Plugin Author [Tobias Bäthge](https://wordpress.org/support/users/tobiasbg/)
 * (@tobiasbg)
 * [5 years, 2 months ago](https://wordpress.org/support/topic/8-latest-rows/#post-14152263)
 * Hi,
 * yes, you can do all that with Shortcode parameters, see [https://tablepress.org/faq/documentation-shortcode-table/](https://tablepress.org/faq/documentation-shortcode-table/)
 * Regards,
    Tobias
 *  Thread Starter [aggk](https://wordpress.org/support/users/aggk/)
 * (@aggk)
 * [5 years, 2 months ago](https://wordpress.org/support/topic/8-latest-rows/#post-14153765)
 * Hi again,
 * Could you please give an example on setting pagination number with shortcode 
   parameters?
    …I could only find “datatables_paginate” which seem to be a boolean
   value?
 * Thanks!
 *  Plugin Author [Tobias Bäthge](https://wordpress.org/support/users/tobiasbg/)
 * (@tobiasbg)
 * [5 years, 2 months ago](https://wordpress.org/support/topic/8-latest-rows/#post-14154011)
 * Hi,
 * ah, the other parameter is not documented that nicely, sorry…
    Please use
 *     ```
       [table id=123 datatables_paginate_entries=4 /]
       ```
   
 * Regards,
    Tobias

Viewing 15 replies - 1 through 15 (of 17 total)

1 [2](https://wordpress.org/support/topic/8-latest-rows/page/2/?output_format=md)
[→](https://wordpress.org/support/topic/8-latest-rows/page/2/?output_format=md)

The topic ‘8 latest rows?’ is closed to new replies.

 * ![](https://ps.w.org/tablepress/assets/icon.svg?rev=3192944)
 * [TablePress - Tables in WordPress made easy](https://wordpress.org/plugins/tablepress/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/tablepress/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/tablepress/)
 * [Active Topics](https://wordpress.org/support/plugin/tablepress/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/tablepress/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/tablepress/reviews/)

 * 17 replies
 * 2 participants
 * Last reply from: [Tobias Bäthge](https://wordpress.org/support/users/tobiasbg/)
 * Last activity: [5 years, 2 months ago](https://wordpress.org/support/topic/8-latest-rows/page/2/#post-14154573)
 * Status: resolved