Forums › Forums › Search & Filter Pro › Excluded categories on specific forms
- This topic has 20 replies, 4 voices, and was last updated 10 years, 4 months ago by Ross.
-
Ross Moderator(Private) July 25, 2014 at 4:51 pm #2929
Hi Joe
As mentioned, this requires me to update the plugin which unfortunately is no simple task – there are many considerations before pushing a plugin update including testing – so sorry I did not get this working quickly for you, but this is above and beyond regular plugin support.
I would say that even pushing an a plugin update within one week to accommodate a specific users requirements is nothing short of extremely fast, so please be patient.
I am dedicating the whole of Sunday now to testing and updating the plugin and then I will be able to help with supplying your additional code to achieve what you specifically require in your setup.
Thanks
Anonymous(Private) July 25, 2014 at 5:00 pm #2930I sent you a message through your contact form. Sorry that this is “above and beyond” plugin support. You were more than willing to help someone achieve this in another support ticket.
This statement will affect all search & Filter forms however, so if you are using more than one form on your site you will need some more conditional statements.. let me know if this is the case?
Ross Moderator(Private) July 25, 2014 at 7:21 pm #2931Hey Joe, it is above and beyond regular support – regular support the way I see it is to make sure a user can get the plugin setup and working as advertised – anything extra is not typically in the realm of support and should be additional work/cost – but… I’m more than happy to do it! Just give me a little time, of course updates etc are for the users which I try to do but these things simply take time..! :/
Ross Moderator(Private) July 27, 2014 at 11:18 pm #2961Hey all…
You can now target the queries from individual forms and modify them using
pre_get_posts
using the following code:function modify_search_filter_query( $query ) { global $sf_form_data; global $wp_query; if ( $sf_form_data->is_valid_form() && $query->is_main_query() && !is_admin()) { if($sf_form_data->form_id()==12) //where the form ID is 12 { //modify the query for a form with id 12 $query->set( 'cat', '-2' ); } else if($sf_form_data->form_id()==99) //where the form ID is 99 { //modify the query for a form with id 99 $query->set( 'cat', '-20' ); } } } add_action( 'pre_get_posts', 'modify_search_filter_query', 21 );
You can get the ID of the form by looking at the URL in the edit screen (when editing your S&F form)
http://www.yoursite.com/wp-admin/post.php?post=797&action=edit
In this case it would be 797.
I’m updating the plugin right now so expect to see it in your dashboards shortly.
Let me know if you have any questions!
Anonymous(Private) July 28, 2014 at 11:46 pm #3010Not sure if this is the most efficient way of doing this but I managed to exclude specific taxonomy terms from specific forms by altering the code above to this.
function modify_search_filter_query( $query ) { global $sf_form_data; global $wp_query; if ( $sf_form_data->is_valid_form() && $query->is_main_query() && !is_admin()) { if($sf_form_data->form_id()==291) { $query->set( 'tax_query', array( array( 'taxonomy' => 'YOUR-TAXONOMY', 'field' => 'id', 'terms' => array( 34,33,32,31,30,29,28,27,26,25,24,23,21 ), 'operator' => 'NOT IN' ) ) ); } } } add_action( 'pre_get_posts', 'modify_search_filter_query', 21 );
-
AuthorPosts