Forums › Forums › Search & Filter Pro › Custom Post Types Missing from Archive
- This topic has 6 replies, 2 voices, and was last updated 8 years, 6 months ago by Anonymous.
-
Anonymous(Private) June 20, 2016 at 7:03 pm #48942
Sooooo,
I’ve just setup a search archive (search.php), and have added it to my search parameters to ensure that custom post types are included using the following code:
// Add Custom Post Types to archives add_filter( 'pre_get_posts', function( \WP_Query $query ) { if ( $query->is_tag() || $query->is_category() || $query->is_author() || $query->is_page_template( 'search.php' ) && $query->is_main_query() ) { $meta_query = array( 'relation' => 'OR', array( 'key' => 'radix_status', 'value' => 'value1', 'compare' => '==', ), array( 'key' => 'radix_status', 'compare' => 'NOT EXISTS', ) ); $query->set( 'post_type', array('post', 'news', 'work', 'events', 'nav_menu_item') ); $query->set( 'order', 'DESC' ); $query->set( 'meta_query', $meta_query ); } } );
But I’ve clearly done something wrong in setting this up, because it’s not working as intended.
I have two issues with it thus far:
1. Custom Post Types aren’t being displayed. They’re listed in the counts, but not showing up in the actual page content.
2. The title of the page refuses to change. I’ve tried the recommended code:
// Edit Search Title add_filter('wp_title','search_form_title'); function search_form_title($title){ global $searchandfilter; if ( $searchandfilter->active_sfid() == 451) { return 'Search Results'; } else { return $title; } }
But it still just says “Opinion” – somehow I’ve got it stuck on JUST that post type?!
Any ideas what I’ve done wrong. I’ve been looking and looking but can’t quite twig.
Anonymous(Private) June 20, 2016 at 7:03 pm #48943Apologies. Link to the search page: http://radix.org.uk/search/
Anonymous(Private) June 22, 2016 at 1:03 pm #49160It is. This seems to be a theme conflict rather than the plugin’s doing. I have it working on my test site, so I’d imagine it’s something to do with the templates/hierarchy loading the POSTS page, rather than the search page. Either way, I’ll figure it out 🙂
Thanks for your help!
-
AuthorPosts