[AUTOMATIQUE] Cet article a plus de 5 ans.
Il se peut donc que les informations qu'il fournit ne soient plus totalement exactes.
Il se peut donc que les informations qu'il fournit ne soient plus totalement exactes.
In most case, it is not relevant to search in some of your internal pages. This is the case for your homes (front page and blog home page). The following snippet let you excludes those pages with the powerfull pre_get_posts filter.
function bweb_search_filter_exclude_frontpage( $query ) { if ( $query->is_search && $query->is_main_query() && !is_admin() ) { $query->set( 'post__not_in', array( get_option('page_on_front'), get_option('page_for_posts') ) ); } } add_action( 'pre_get_posts', 'bweb_search_filter_exclude_frontpage' );
All you have to do is to open your functions.php file (in your child theme) and paste the function.