Forums › Forums › Search & Filter Pro › Additional Post Type required
Tagged: post type
- This topic has 8 replies, 3 voices, and was last updated 8 years, 7 months ago by Ross.
-
Anonymous(Private) April 11, 2016 at 9:44 pm #42374
Hi there
Great plugin, thank you!
We have a problem though – the WordPress theme that we’re using has a particular Post Type, called Tours, which is not present in your Plugin.Here’s the theme FYI: adventure-tours.themedelight.com
How do we go about searching content of this nature, is there a way for us to introduce a new Post Type so that your plugin can find and search the area that our content is in?
Let me know if you need more info, thank you!
Trevor(Private) April 12, 2016 at 10:58 am #42422Hi. I can see the issue and need to refer this to our devs. They may also require ftp access to examine the plugin that sets up the Tours CPT within WooCommerce. So, if you are able to provide those details and credentials, that may speed things up a bit. I will hand ownership of this thread over to Ross for now.
Ross Moderator(Private) April 12, 2016 at 12:23 pm #42443Hey Judy
I took a look but couldn’t see anything.
I think the issue is to do with the way your theme changes certain aspects of the Post Type Products – and renaming them to Tours and changing your shop page.
The first thing I would try to do is disable your other plugins – I know you don’t have an extensive list however its good to cross that off the list.
Once you’ve done that let me know and if there are still issues we can look into them further – as Trevor said, I might need to request further access details.
Thanks
Ross Moderator(Private) April 18, 2016 at 12:26 am #43026Hi Judy
Ok so I managed to solve the issue 🙂 It wasn’t easy…
So, let me explain what has happened.
The results were always being set to
0
because the query for S&F was being “hijacked” by your theme.I say hijacked, but its completely standard practise to write filters for modifying queries, but when they are added too loosely, these modifications can have unintended effects.
Essentially this is a theme issue, and it would probably be a good idea to loop the theme devs back in here.
Basically, in the class WC_Tour_Query (in the woocommerce/inludes/ folder in your parent theme), there is a
pre_get_posts
filter which makes some modifications to queries.The issue is, it was modifying S&F queries too. The reason this is a theme issue though is because they have this condition:
if ( ! $q->is_main_query() ) { if ( 'product' == $q->get( 'post_type' ) ) {
This means, they modify ANY query that is querying the post type “product”. Now this has greater consequences, because any plugin (not just S&F) that makes use of WP_Query (which is pretty common, its a great class) and it happens to be querying the “product” post type, will be modified by your theme. This loose condition has the potential to break an array of different plugins.
What we do with S&F, to avoid this kind of issue, is to attach a variable to all our queries, and befoer we modify any query we check to see if its there.
This way there is no chance of modifying something unintended.
Anyway, as a quick fix, I modified this file around line
33
– and made sure that the query was not modified if it is a query belonging to S&F:It was:
$q->set( 'tax_query', $cur_tax_query );
And I’ve updated to:
if(!isset($q->query_vars['search_filter_id'])) { $q->set( 'tax_query', $cur_tax_query ); }
This is the quick fix, the better one is to get your theme authors to take a look at this thread.
As an FYI, I tried to put this modification in to your child theme (woocommerce/templates/WC_Tour_WP_Query.php) but it wasn’t being picked up, so I made the modification in the parent theme, and created a backup of the previous file called
WC_Tour_WP_Query_Bkp.php
🙂
PS, if you update your theme, you will lose the changes I have made, you will have to re-apply them with every update unless your theme authors make the modification above.
I’m happy to talk to them directly and explain further.
Thanks
-
AuthorPosts