How do you get facet widgets to appear on a custom post type / taxonomy page?
- ukdesignservicesParticipant5 years, 2 months ago #13505
Is it possible to get the facets and sort widgets to appear on custom post type taxonomy pages?
I’ve systematically tried every ‘Replace WordPress archives’ option, updating my permalinks each time, but the sidebar fails to render any widgets? I’m trying to add filtering to my product taxonomies.Many thanks
ukdesignservicesParticipant5 years, 2 months ago #13507Thanks for your reply. Unfortunately this is not working for me. I have checked ‘Custom post types’ in screen 2.1 but neither the sort or facets widgets are rendering.
Debugging, I can see that:
return self::$is_replace_by_wpsolr_query;
returns false before checkingWPSOLR_Service_Container::getOption()->get_search_is_replace_default_wp_post_type()
Any idea how I can fix this?
Many thanks
ukdesignservicesParticipant5 years, 2 months ago #13508Okay, I think I’ve found the issue. It looks like it will work on an archive of all posts of a given type, but not on a taxonomy term.
Could you advise on how to extend
get_is_replace_by_wpsolr_query()
to include a condition for:$is_replace_by_wpsolr_query = (is_archive() && is_tax());
Many thanks
ukdesignservicesParticipant5 years, 2 months ago #13510Thanks but unfortunately that’s not making any difference.
I have tried with everything checked:
https://www.dropbox.com/s/sc19dc127dhi607/replace-archives.PNG?dl=0
but the widgets are still not rendering.Looking at get_is_replace_by_wpsolr_query():
$is_replace_by_wpsolr_query = ! is_admin() && is_main_query() && WPSOLR_Service_Container::getOption()->get_search_is_use_current_theme_search_template(); if ( $is_replace_by_wpsolr_query ) { $is_replace_by_wpsolr_query = false; /** * Search */ if ( ! $is_replace_by_wpsolr_query && WPSOLR_Service_Container::getOption()->get_search_is_replace_default_wp_search() ) { $is_replace_by_wpsolr_query = is_search(); } /** * WordPress post archives */ if ( ! $is_replace_by_wpsolr_query && WPSOLR_Service_Container::getOption()->get_search_is_replace_default_wp_home() ) { $is_replace_by_wpsolr_query = is_home(); } if ( ! $is_replace_by_wpsolr_query && WPSOLR_Service_Container::getOption()->get_search_is_replace_default_wp_author() ) { $is_replace_by_wpsolr_query = is_author(); } if ( ! $is_replace_by_wpsolr_query && WPSOLR_Service_Container::getOption()->get_search_is_replace_default_wp_year() ) { $is_replace_by_wpsolr_query = is_year(); } if ( ! $is_replace_by_wpsolr_query && WPSOLR_Service_Container::getOption()->get_search_is_replace_default_wp_month() ) { $is_replace_by_wpsolr_query = is_month(); } if ( ! $is_replace_by_wpsolr_query && WPSOLR_Service_Container::getOption()->get_search_is_replace_default_wp_day() ) { $is_replace_by_wpsolr_query = is_day(); } if ( ! $is_replace_by_wpsolr_query && WPSOLR_Service_Container::getOption()->get_search_is_replace_default_wp_category() ) { $is_replace_by_wpsolr_query = is_category(); } if ( ! $is_replace_by_wpsolr_query && WPSOLR_Service_Container::getOption()->get_search_is_replace_default_wp_tag() ) { $is_replace_by_wpsolr_query = is_tag(); } if ( ! $is_replace_by_wpsolr_query && WPSOLR_Service_Container::getOption()->get_search_is_replace_default_wp_post_type() ) { $is_replace_by_wpsolr_query = is_post_type_archive(); } }
I don’t see how
$is_replace_by_wpsolr_query
will ever return true on a custom taxonomy page on a custom post type.wpsolrKeymaster5 years, 2 months ago #13511$is_replace_by_wpsolr_query = is_category();
$is_replace_by_wpsolr_query = is_tag();but then:
$is_replace_by_wpsolr_query = apply_filters( WPSOLR_Events::WPSOLR_FILTER_IS_REPLACE_BY_WPSOLR_QUERY, $is_replace_by_wpsolr_query );For instance, our WooCommerce extension uses this filter to change the value.
ukdesignservicesParticipant5 years, 2 months ago #13512Thank you, I’ll try that.
memphdutchParticipant4 years, 5 months ago #19443I want to use this with a custom taxonomy. If I created a custom plugin so that I wasn’t editing the actual plugin, what would I need to include prior to these lines of code to help it understand the context? Or is there a better way to do it?
wpsolrKeymaster4 years, 5 months ago #19448Custom taxonomies archives should work already, since https://www.wpsolr.com/forums/topic/release-21-6/
memphdutchParticipant4 years, 5 months ago #19451I am using the same template for my search page as well as custom taxonomy archives. The sidebar filters work on the search page but do not work on the custom taxonomy pages. I don’t see in the WPSOLR settings how to make that active. I am on version 21.8 of the plugin.
Screenshots:
https://www.dropbox.com/s/t4a6qixgjs4jhvm/Screen%20Shot%202020-04-15%20at%2010.08.46%20AM.png?dl=0
https://www.dropbox.com/s/9qnwfac9v7hsfem/Screen%20Shot%202020-04-15%20at%2010.08.59%20AM.png?dl=0
https://www.dropbox.com/s/aqnvf9wdzyz8eya/Screen%20Shot%202020-04-15%20at%2010.09.08%20AM.png?dl=0
https://www.dropbox.com/s/roq9yje2dxyp2it/Screen%20Shot%202020-04-15%20at%2010.09.30%20AM.png?dl=0
memphdutchParticipant4 years, 5 months ago #19456Any thoughts on this? The sidebar facets on my custom taxonomy archives are not working even though they use the identical template to the search page.
memphdutchParticipant4 years, 5 months ago #19458I created them with Custom Post Type UI https://wordpress.org/plugins/custom-post-type-ui/
All of the configuration is default. Here are screenshots:
https://www.dropbox.com/s/qzwjzl1ujnp5nqq/Screen%20Shot%202020-04-17%20at%202.37.56%20PM.png?dl=0https://www.dropbox.com/s/rxpusbw2djxt689/Screen%20Shot%202020-04-17%20at%202.39.26%20PM.png?dl=0
wpsolrKeymaster4 years, 5 months ago #19462Here is a version with a fix to let facets appear on custom taxonomies archives:
https://www.dropbox.com/s/h3g4lzr3jv2ezwq/wpsolr-pro-fix-missing-custom-tax-archives.zip?dl=0Let me know how it goes.
You must be logged in to reply to this topic.