• Resolved prestonm

    (@prestonm)


    Hi Tobias,

    I mentioned this on your twitter thread.

    screen shot table listing

    The default sort column of the plugin is the keyfield (ID). I would like the default sort to be some other field. Perhaps the first “human” column, which is “Table Name”. Or, preferably, a setting to allow default column to be set by the individual site owner.

    In my case, I would set the default to “Last Modified”, as that way the tables I work with most would be at the top of the listing, not buried down on other listing pages, as new tables will be as they are created (with ever higher ID values).

    Note: This is on the listing of all tables, not within the setup of each individual table.

    Hopefully, that makes sense? 🙂

    If there is already a way to do that, please let me know.

    Thank you,

    Preston

Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Author Tobias Bäthge

    (@tobiasbg)

    Hi,

    thanks for your question, and sorry for the trouble.

    I see what you mean, but unfortunately, I’m now aware of a quick way to modify this, I’m afraid. 🙁
    TablePress is using some WordPress code for this, so that I can not simply change it.
    Now, achieving this might be possible, by pre-defining a orderby parameter, but I’m not sure how that code would have to look like at the moment.

    Regards,
    Tobias

    Plugin Author Tobias Bäthge

    (@tobiasbg)

    Hi again,

    wait, this might not even be too hard. Setting that parameter could be done in a filter hook. Please try adding this to your theme’s “functions.php” file:

    add_filter( 'tablepress_view_data', 'prestonm_tablepress_default_sort_order', 10, 2 );
    function prestonm_tablepress_default_sort_order( $data, $action ) {
      if ( 'list' === $action ) {
        if ( empty( $_GET['orderby'] ) && empty( $_POST['orderby'] ) ) {
          $_GET['orderby'] = 'table_last_modified';
          $_GET['order'] = 'desc';
        }
      }
      return $data;
    }

    Note that I did not test this, so it might not work. 🙁

    Regards,
    Tobias

Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘Default sort column’ is closed to new replies.