Docs & Support

Learn about all the Formidable features and get support from our amazing customer success team.

ViewsView Examples
How to Sort a View Across Multiple Pages

How to Sort a View Across Multiple Pages

Show form submissions on a page and let visitors sort a View across multiple pages. They can sort by values on the page, including values shown on other pages when the View uses pagination. If your View is a table without pagination, read how to make a sortable table.

Create the View

If you haven't created a View yet, start there. Set a Page Size in the View settings so the entries are split across pages.

Formidable Forms makes advanced site building simple. Launch forms, directories, dashboards, and custom WordPress apps faster than ever before.

Once your View is complete, add links to sort the data. For example, you may have a table header that looks like this:

Table header before
<th>Date</th>

Change this label to a link.

<th><a href="?frmsort=25&frmdir=[if get param='frmdir' equals='asc']desc[/if get][if get param='frmdir' not_equal='asc']asc[/if get]">Date</a></th>

In this link, replace 25 with the ID of the field to order by when Date is clicked. Each time a visitor clicks this link, it switches between frmsort=25&frmdir=asc and frmsort=25&frmdir=desc to change the direction of the sorting.

Add as many sorting links as you need. Change the field ID in each link.

Sort the View

Next, tell your View how to use the frmsort and frmdir values. This needs a custom shortcode that uses the PHP alternative to insert a View.

Learn where to put the code when adding a custom PHP function to your site.
Sort a View with URL parameters
add_shortcode( 'sort-frm-view', 'sort_frm_view_shortcode' );
function sort_frm_view_shortcode( $atts ) {
  if ( isset( $_GET['frmsort'] ) ) {
    $atts['order_by'] = sanitize_text_field( $_GET['frmsort'] );
  }
  if ( isset( $_GET['frmdir'] ) ) {
    $atts['order'] = sanitize_text_field( $_GET['frmdir'] );
  }
  return FrmViewsDisplaysController::get_shortcode( $atts );
}

This shortcode reads frmsort and frmdir from the page URL and passes them to the View as its order_by and order values.

Insert the View on a page

Since you have a custom shortcode, insert the View on the page a bit differently than normal. Use sort-frm-view in place of display-frm-data in your shortcodes. If your original View shortcode looked like this:

[display-frm-data id=150 filter=limited limit=10]

then the new shortcode is:

[sort-frm-view id=150 filter=limited limit=10]

Dynamically sort the content

Now the order of entries in the View changes each time a visitor clicks a sort link. The sort order stays the same when they go to the next page of the View. This works for any number of fields.

Limitations

  • A column that shows a Dynamic field value, such as [151 show=31], isn't sorted by the text it shows. A Dynamic field saves the ID of the linked entry, so the View sorts by that ID. The IDs are compared as text. As a result, the order is neither alphabetical nor always the order the linked entries were created. For example, an entry linked to ID 1000 comes before one linked to ID 999.
  • To sort by the text, use a Lookup field in place of the Dynamic field and sort by the Lookup field's ID. A Lookup field saves the text itself. Unlike a Dynamic field, its saved value doesn't change when the original entry is edited. Learn more about the differences between Dynamic and Lookup fields.
Was this article helpful? *

This article may contain affiliate links. Once in a while, we earn commissions from those links. But we only recommend products we like, with or without commissions.

In this article

    We have a small, but amazing team of dedicated people who are committed to helping you achieve your goals and project requirements.


    Copyright © 2026 Strategy11, LLC. Formidable Forms® is a registered trademark Strategy11, LLC.

    Complete your purchase
    Don't forget your purchase!
    Complete Purchase
    Join 400,000+ using Formidable Forms to create form-focused solutions fast. Get Formidable Forms