Add custom post types to WordPress search. Code example open

Add custom post types to WordPress search. Code example

Approved. Code works!
This is exactly the working code that is verified by the moderator or site administrators
function somarket_search_all( $query ) {
	if ( $query->is_search ) {
		$query->set( 'post_type', array(
			'post', 'page', 'products', 'wiki', 'places', 'product'
		) );
	}
	return $query;
}
add_filter( 'the_search_query', 'somarket_search_all' );
0

More

Leave a Reply

Your email address will not be published. Required fields are marked *

How many?: 22 + 22

lil-code© | 2022 - 2024
Go Top
Authorization
*
*
Registration
*
*
*
*
Password generation