• Resolved eleonoli

    (@eleonoli)


    Hi,

    Is it possible to use shortcode for showing only last 10 rows of table (if pagination is not enabled in the DataTables JavaScript library)?

    Thanks!

Viewing 1 replies (of 1 total)
  • Plugin Author TobiasBg

    (@tobiasbg)

    Hi,

    thanks for your post, and sorry for the trouble.

    The only solution that I can think of right now is to define a custom Shortcode. For that, please add this to your theme’s functions.php file:

    add_shortcode( 'table-last-ten-rows', 'tablepress_last_ten_rows_shortcode' );
    function tablepress_last_ten_rows_shortcode( $atts ) {
      $number_table_rows = tablepress_get_table_info( array( 'id' => $atts['id'], 'field' => 'number_rows' ) );
      $atts['hide_rows] = '1-' . ( $number_table_rows - 10 );
      return tablepress_get_table( $atts );
    }

    Now, you can use a Shortcode like

    [table-last-ten-rows id=123 /]
    

    Regards,
    Tobias

Viewing 1 replies (of 1 total)
  • The topic ‘shortcode for rows per page’ is closed to new replies.