This topic has 3 replies, 2 voices, and was last updated 5 years, 1 months ago ago by Olga Barlow
I have the search option in the theme’s settings set to “posts and pages” however, when I search for example “mississauga” it only shows posts. The search query seems wrong.
The URL generated is:
https://pfc.igosalesandmarketing.com/?s=mississauga&post_type=post
And it only shows posts, it should be:
https://pfc.igosalesandmarketing.com/?s=mississauga&post_type=post&post_type=page
I have some custom post types that aren’t showing up. Can you direct me to where this is generated in the functions so I can add the appropriate url reference to search pages as well?
Ok found this in theme-functions.php
// **********************************************************************//
// ! Add page to search results
// **********************************************************************//
add_filter( 'pre_get_posts', 'et_search_filter' );
if ( !function_exists('et_search_filter') ) {
function et_search_filter( $query ) {
if ( ! is_admin() ) {
if ( isset($query->query['post_type']) ) {
if ( $query->is_search && $query->query['post_type'] == 'post') {
$query->set( 'post_type', array( 'post', 'page' , 'industries', 'wpsl_stores' ) );
}
}
return $query;
}
}
}
I added my two custom post types here “industries” and “wpsl_stores”
I just added this to the functions.php of the child theme.
Sorry answered my own questions, but if someone else has the problem, this is the solution.
Hello,
We glad to hear that you sorted out and share your solution with other customers!
Feel free to contact us if you need any other help.
Regards
You must be logged in to reply to this topic.Log in/Sign up