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

Learn how to show form submissions on a page, and sort a view across pages. This allows users to sort by values on the page, including values that are shown on a different page when using pagination. If your view is a table without pagination, read how to make a sortable table. Note: This isn't set up to work with Dynamic fields.

Create the view

If you haven't created a view yet, start there.

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:

<th>Date</th>

This label needs to be switched 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. Now, each time you click this link it will switch between frmsort=25&frmdir=asc and frmsort=25&frmdir=desc to change the direction of the sorting.

Add as many different sorting links that you would like. Be sure to change the field id in each link.

Sort the view

All that is left is to tell your view how to use the frmsort and frmdir values. To do this, we'll need a custom shortcode that uses the PHP alternative to insert a view.

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 );
}

Insert the view on a page

Since you have a custom shortcode, the view will be inserted on the page a bit differently than normal. Now you will 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]

the new shortcode will be:

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

Dynamically sort the content

Now the order of entries in the view will change each time a link is clicked. This covers any number of fields that you would like to sort.

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 © 2025 Strategy11, LLC. Formidable Forms® is a registered trademark Strategy11, LLC.

    Join 400,000+ using Formidable Forms to create form-focused solutions fast. Get Formidable Forms