Title: Specifying Sort fields
Last modified: August 22, 2016

---

# Specifying Sort fields

 *  Resolved [NicolasMous](https://wordpress.org/support/users/nicolasmous/)
 * (@nicolasmous)
 * [11 years, 7 months ago](https://wordpress.org/support/topic/specifying-sort-fields/)
 * Dear xnau,
 * Is it possible to specify certain fields that are shown in the sorting drop down
   list and excluding the other fields?
 * The thing is, i have multiple pages with a search and sort option. The search
   possibilities are however different on these pages, the search fields are specified
   with ‘_fields=””_‘, which only makes it possible to search for the defined database
   fields. Though, the sort option does not have a way to specify certain database
   fields, it rather shows ALL the field groups instead of the defined fields.
 * So the question is, is it possible to also specify the sorting fields, for example,
   on page 1 you can only sort fields A,B and C while on page 2 you can only sort
   fields D,E and F.
 * Thanks in advance!
 * [https://wordpress.org/plugins/participants-database/](https://wordpress.org/plugins/participants-database/)

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

 *  Plugin Author [xnau webdesign](https://wordpress.org/support/users/xnau/)
 * (@xnau)
 * [11 years, 7 months ago](https://wordpress.org/support/topic/specifying-sort-fields/#post-5201480)
 * Yes, you’ll need to get into working with a custom template.Check this article
   for the basic technique, then use the “pdb-list-detailed.php” template as your
   starting point. It includes comments to help you customize the search and sort
   controls.
 * [How to Create Custom Templates](http://xnau.com/work-2/wordpress-plugins/participants-database/pdb-templates/)
 *  Thread Starter [NicolasMous](https://wordpress.org/support/users/nicolasmous/)
 * (@nicolasmous)
 * [11 years, 7 months ago](https://wordpress.org/support/topic/specifying-sort-fields/#post-5201557)
 * Dear xnau,
 * So I have created a new template based on “pdb-list-detailed.php”.
 * I also found the right line of code (at least I think I did) to edit my sorting
   list:
 *     ```
       <?php       /*
              * this function sets the fields in the sorting dropdown. It has two options:
              *    1. columns: an array of field names to show in the sorting dropdown. If
              *       'false' shows default list of sortable fields as defined
              *    2. sorting: you can choose to sort the list by 'column' (the order they
              *       appear in the table), 'alpha' (alphabetical order), or 'order' which
              *       uses the defined group/field order
              */
             $this->set_sortables(false, 'alpha');
             ?>
       ```
   
 * So if I am not mistaken I will have to set the false to columns right? How is
   the syntax though for specifying the columns that I want to show?
 * Sorry for the newbieness..
    Thankss in advance!
 *  Thread Starter [NicolasMous](https://wordpress.org/support/users/nicolasmous/)
 * (@nicolasmous)
 * [11 years, 7 months ago](https://wordpress.org/support/topic/specifying-sort-fields/#post-5201559)
 * *Update:
 * So I found the **‘Adding an Edit Record Link to the Frontend List’** and thought
   perhaps it would also be possible with this.
 * So I followed the tutorial and created the link, though this tutorial (and code)
   doesn’t seem to work on multiselect boxes and their values.. And though, if it
   worked it still needed some kind of if statement to look which of the multiselect
   options was chosen (if option 1 was chosen –> then insert a link to website/page
   A and if option 2 was chosen –> then insert a link to website/page B.
 *  Thread Starter [NicolasMous](https://wordpress.org/support/users/nicolasmous/)
 * (@nicolasmous)
 * [11 years, 7 months ago](https://wordpress.org/support/topic/specifying-sort-fields/#post-5201564)
 * *ignore above post as it wasn’t supposed to go in here!
 *  [Website Ink](https://wordpress.org/support/users/websiteink/)
 * (@websiteink)
 * [11 years, 7 months ago](https://wordpress.org/support/topic/specifying-sort-fields/#post-5201607)
 * Hi NicolasMous, did you manage to sort out your problem?
 * I have a birthday list and Tel Directory which is on 2 different pages and each
   page needs its own sort function.
 * I created a custom template for this and did the changes which I though would
   work but it doesn’t. How do I assign the new template only to the Birthdays page?
   Also how do I get the Sort function to work the way I want it to work?
 * Any help would be greatly appreciated.
 * Thanks
 *  [Website Ink](https://wordpress.org/support/users/websiteink/)
 * (@websiteink)
 * [11 years, 7 months ago](https://wordpress.org/support/topic/specifying-sort-fields/#post-5201608)
 * xnau, please help.
 * Here is my code, but for some reason it still shows all the fields instead of
   only first_name & calendar_month
 *     ```
       <?php if ( $filter_mode == 'sort' || $filter_mode == 'both' ) : ?>
   
           <fieldset class="widefat">
             <legend><?php _e('Sort by', 'participants-database' )?>:</legend>
   
             <?php
             /*
              * this function sets the fields in the sorting dropdown. It has two options:
              *    1. columns: an array of field names to show in the sorting dropdown. If
              *       'false' shows default list of sortable fields as defined
              *    2. sorting: you can choose to sort the list by 'column' (the order they
              *       appear in the table), 'alpha' (alphabetical order), or 'order' which
              *       uses the defined group/field order
              */
             $this->set_sortables(true, 'first_name, calendar_month');
             ?>
   
             <?php $this->sort_form() ?>
       ```
   

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

The topic ‘Specifying Sort fields’ is closed to new replies.

 * ![](https://ps.w.org/participants-database/assets/icon-256x256.jpg?rev=1389807)
 * [Participants Database](https://wordpress.org/plugins/participants-database/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/participants-database/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/participants-database/)
 * [Active Topics](https://wordpress.org/support/plugin/participants-database/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/participants-database/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/participants-database/reviews/)

## Tags

 * [database](https://wordpress.org/support/topic-tag/database/)
 * [sorting](https://wordpress.org/support/topic-tag/sorting/)

 * 6 replies
 * 3 participants
 * Last reply from: [Website Ink](https://wordpress.org/support/users/websiteink/)
 * Last activity: [11 years, 7 months ago](https://wordpress.org/support/topic/specifying-sort-fields/#post-5201608)
 * Status: resolved