Archived Post Shows Up In Site Search
-
Archived posts show up in the default WordPress site search
https://example.com/?s=keyword
You could add a bit of code to remove archived from the search
function wb_search_filter_archived( $query ) { if ( ! is_admin() && $query->is_main_query() ) { // Not a query for an admin page. // It's the main query for a front end page of your site. $query->set( 'post_status', array( 'publish' ) ); } } add_action( 'pre_get_posts', 'wb_search_filter_archived');
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
- The topic ‘Archived Post Shows Up In Site Search’ is closed to new replies.