Forums › Forums › Search & Filter Pro › Taxonomy archive for shared taxonomy broken
Tagged: hook, shared taxonomy
- This topic has 11 replies, 3 voices, and was last updated 7 years ago by Anonymous.
-
Anonymous(Private) November 1, 2017 at 9:23 am #139560
I have a number of CPTs defined. All have unique taxonomies, some have shared ones (ie a taxonomy that can categorise multiple post types).
I have designed search forms for each post type (unique to it, includes post type specific taxonomy values etc) – I’ve enabled only a single post type per form. If I check the “Enable filtering on Taxonomy Archives?” box, I get great interactivity when browsing taxonomy pages that are post type specific. But if I’m browsing a tax archive that’s shared between post types (and should return posts from all CPTs, I see only results from the post type selected in the taxonomy-unique form. This is because I can see that S&F has modified the search query to only show the single post type.
This is the main query I end up with, on a shared taxonomy archive page.
SELECT SQL_CALC_FOUND_ROWS wp_posts.ID FROM wp_posts LEFT JOIN wp_term_relationships ON (wp_posts.ID = wp_term_relationships.object_id) WHERE 1=1 AND wp_posts.ID IN (0) AND ( wp_term_relationships.term_taxonomy_id IN (22224) ) AND wp_posts.post_type = 'build' AND ((wp_posts.post_status = 'publish')) GROUP BY wp_posts.ID ORDER BY wp_posts.post_date DESC LIMIT 0, 10
Where 22224 is the id of a term from the shared taxonomy, and ‘build’ is one of 3 post types that can have that term applied.
I need a means to conditionally unhook the SF query modification, so that the tax archive magic (which I like) only occurs on the taxonomy archives I define. Is this as simple as running a pre_get_posts hook after the Search_Filter->archive_query_init_later() hook has run, that conditionally unsets the search ID so that the post type condition is not subsequently set?
Trevor(Private) November 1, 2017 at 9:38 am #139562If (and that is a BIG assumption) I understand you right, you want the page to show results based on your query if no filter has been run, and use S&F query IF a filter has been run?
If, so MAYBE this would help:
https://support.searchandfilter.com/forums/topic/results-appear-only-on-submit/#post-116180
Where you can have different code in the template in each yes/no section.
Anonymous(Private) November 1, 2017 at 10:16 am #139566Let me try again.
I want to use the automagic “Enable filtering on Taxonomy Archives” on some taxonomy archives of a post type, but not all.
I’ve read the source and I can see that the way the magical ‘attachment’ to tax archives works is something like, ( in
Search_Filter->archive_query_init_later()
):Is the current taxonomy archive associated with one of the post types that one of my forms uses, and if so, and $enable_taxonomy_archives is true, then baam, I'll add a post_type argument to the query to match only those post types selected in the form setup (this query tweaking happens in a subsequent hook - initially, it just sets the search_filter_id at that point).
I need to selectively stop this from happening on some shared taxonomy archives, because it is excluding results from other post types on those tax archive screens.
I’m not even showing the form on the archive pages in question, but the hook, and associated unwanted query conditions, are still running, in the background, and breaking the share archives.
Anonymous(Private) November 12, 2017 at 11:40 pm #141522I’m a paid customer, and I’d appreciate some feedback please. The beta version of the plugin that you supplied addressed my original issue, but there are several others that have cropped up.
I’ll start another thread with the latest I’ve detected, but either way, I’d like some help. The site I’m using your plugin on is complex with a large number of taxonomies and custom post types. Your plugin appeared, at first glance to be a good fit for a us, but as further issues emerge, we’re getting nervous as to whether it is going to work.
Ross Moderator(Private) November 12, 2017 at 11:45 pm #141525Hi Rob
I missed your last post, apologies.
I’ll take a look at your latest issue tomorrow and get this sorted.
Thanks
-
AuthorPosts