Title: Dynamic filtering?
Last modified: August 30, 2016

---

# Dynamic filtering?

 *  Resolved [dlongm01](https://wordpress.org/support/users/dlongm01/)
 * (@dlongm01)
 * [10 years, 8 months ago](https://wordpress.org/support/topic/dynamic-filtering-2/)
 * HI
 * Nice plugin and very useful.
 * I have scanned the forum but can’t find the exact answer I need (although I think
   the answer will be ‘no’ at the present time!).
 * I’d like to filter my list dynamically, e.g., using a drop down to choose a category.
 * E.g. I have a list of publications. These are classified using categories. I’d
   like to have a category list in a drop down field so that when a user selects
   a category the sticky list displays the items in that category.
 * I realise that the current shortcode format won’t do this (or will it?) but if
   you could suggest some code to suggest that might be added to functions.php I
   would be grateful.
 * Thanks
 * [https://wordpress.org/plugins/gravity-forms-sticky-list/](https://wordpress.org/plugins/gravity-forms-sticky-list/)

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

 *  Plugin Author [fried_eggz](https://wordpress.org/support/users/fried_eggz/)
 * (@fried_eggz)
 * [10 years, 8 months ago](https://wordpress.org/support/topic/dynamic-filtering-2/#post-6653920)
 * Sure, this should be fairly simple. You can probably hook into [list.js](http://www.listjs.com/)(
   used to sort and filter the list).
 * If you enable list search (in Sticky List settings) you will se a search bar 
   above the list. What you need then is a dropdown that, when changed, populates
   the search field. You can also hide the search field if you dont want it.
 * You will need some basic javascript and CSS to accomplish this.
 *  Plugin Author [fried_eggz](https://wordpress.org/support/users/fried_eggz/)
 * (@fried_eggz)
 * [10 years, 8 months ago](https://wordpress.org/support/topic/dynamic-filtering-2/#post-6653929)
 * This was actually very simple.
 * Just put a select in your page template with all the categories, example:
 *     ```
       <select id='my_filter_select'>
       	<option>First</option>
       	<option>Second</option>
       	<option>Third</option>
       </select>
       ```
   
 * Then put this in functions.php
 *     ```
       add_action( 'wp_head', 'my_filter_entries' );
       function my_filter_entries() {
       	?>
       	<script type="text/javascript">
       	jQuery(document).ready(function($) {
       		$('#my_filter_select').change(function(event) {
       			userList.search($(this).val());
       		});
       	});
       	</script>
       <?php }
       ```
   
 *  Thread Starter [dlongm01](https://wordpress.org/support/users/dlongm01/)
 * (@dlongm01)
 * [10 years, 8 months ago](https://wordpress.org/support/topic/dynamic-filtering-2/#post-6653935)
 * Marvellous – thanks. Looks like a good solution. HTML fine but but when I tried
   code in functions.php it crashed my site! Dead, late, no more.
 * Writing for the techs to revive it … fingers crossed, heart bearing anxiously.
 * From your point of view is the PHP OK? I don’t know enough to say one way or 
   the other. I am slightly puzzled by the 3rd line and the very last line, but 
   what do I know!
 *  Thread Starter [dlongm01](https://wordpress.org/support/users/dlongm01/)
 * (@dlongm01)
 * [10 years, 8 months ago](https://wordpress.org/support/topic/dynamic-filtering-2/#post-6653937)
 * Site back! Phew!
 *  Plugin Author [fried_eggz](https://wordpress.org/support/users/fried_eggz/)
 * (@fried_eggz)
 * [10 years, 8 months ago](https://wordpress.org/support/topic/dynamic-filtering-2/#post-6653945)
 * Thats very strange. The code above should not break anything. Try this instead.
   In your page template, insert:
 *     ```
       <select id='my_filter_select'>
       	<option>First</option>
       	<option>Second</option>
       	<option>Third</option>
       </select>
       <script type="text/javascript">
       jQuery(document).ready(function($) {
       	$('#my_filter_select').change(function(event) {
       		userList.search($(this).val());
       	});
       });
       </script>
       ```
   
 *  Thread Starter [dlongm01](https://wordpress.org/support/users/dlongm01/)
 * (@dlongm01)
 * [10 years, 8 months ago](https://wordpress.org/support/topic/dynamic-filtering-2/#post-6653965)
 * fried_eggz that’s marvellous. Works a treat and seems to do just what I need.
   Thank you.
 *  Plugin Author [fried_eggz](https://wordpress.org/support/users/fried_eggz/)
 * (@fried_eggz)
 * [10 years, 8 months ago](https://wordpress.org/support/topic/dynamic-filtering-2/#post-6653981)
 * No problem, glad I could help. If you need the select drop-down to be automatically
   populated with the categories, that can be done too.
 * Anyways, if you like the plugin and the support, please consider writing a short
   [review](https://wordpress.org/support/view/plugin-reviews/gravity-forms-sticky-list).
   Thanks!
 *  Thread Starter [dlongm01](https://wordpress.org/support/users/dlongm01/)
 * (@dlongm01)
 * [10 years, 8 months ago](https://wordpress.org/support/topic/dynamic-filtering-2/#post-6653983)
 * “…to be automatically populated with the categories…”
 * Yes please. That would be useful and interesting o know how to do that.
 * And yes, will write a review.
 *  Plugin Author [fried_eggz](https://wordpress.org/support/users/fried_eggz/)
 * (@fried_eggz)
 * [10 years, 8 months ago](https://wordpress.org/support/topic/dynamic-filtering-2/#post-6654027)
 * OK, if we are talking about standar WordPress categories, you can try this code
   instead of the code posted above.
 *     ```
       <select id='my_filter_select'>
       	<?php $categories = get_categories();
         	foreach ($categories as $category) { ?>
       	<option><?php echo $category->cat_name; ?></option>
       	<?php } ?>
       </select>
   
       <script type="text/javascript">
       jQuery(document).ready(function($) {
       	$('#my_filter_select').change(function(event) {
       		userList.search($(this).val());
       	});
       });
       </script>
       ```
   
 *  Thread Starter [dlongm01](https://wordpress.org/support/users/dlongm01/)
 * (@dlongm01)
 * [10 years, 8 months ago](https://wordpress.org/support/topic/dynamic-filtering-2/#post-6654029)
 * Thanks fried_eggz
 * Great support as usual – I can’t try this just now as the site is having some
   back-end maintenance but will do in the next few days.

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

The topic ‘Dynamic filtering?’ is closed to new replies.

 * ![](https://s.w.org/plugins/geopattern-icon/gravity-forms-sticky-list_9b65b3.
   svg)
 * [Gravity Forms Sticky List](https://wordpress.org/plugins/gravity-forms-sticky-list/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/gravity-forms-sticky-list/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/gravity-forms-sticky-list/)
 * [Active Topics](https://wordpress.org/support/plugin/gravity-forms-sticky-list/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/gravity-forms-sticky-list/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/gravity-forms-sticky-list/reviews/)

 * 10 replies
 * 2 participants
 * Last reply from: [dlongm01](https://wordpress.org/support/users/dlongm01/)
 * Last activity: [10 years, 8 months ago](https://wordpress.org/support/topic/dynamic-filtering-2/#post-6654029)
 * Status: resolved