In WordPress, we add custom post types for various purposes. But WordPress custom post type did not automatically show this post in the search result. In this case, we have to enable it to show in the search result.
HOW?
Add the below codes in your theme’s functions.php file. If you have videos, news, and articles for custom post type then add them in the array like below.
function themejelly_search_filter($query) {
if ($query->is_search) {
$query->set( 'post_type', array( 'post', 'page', 'videos', 'news', 'aticles') );
}
return $query;
}
add_filter('parse_query', 'themejelly_search_filter');
Here themejelly_search_filter is the name of functions. It can be any name.
Aminul Islam is a WordPress theme developer and developed this website's theme. He also the content writer of this website.
The Footer of the WordPress dashboard area shows the message of the credit of the theme. We can change this… details