Documentation

View the installation guide, browse the Knowledge Base, find out about SearchWP's many hooks, get support

SEO Framework Exclude from Local Search

SEO Framework is a popular search engine optimization plugin for WordPress, and it includes a handy checkbox to prevent the current entry from being included in local search results:

Screenshot of local search exclusion checkbox in SEO Framework

SEO Framework local search exclusion

You can easily integrate SearchWP with this setting by adding the following to your theme’s functions.php:

<?php
function my_searchwp_seo_framework_integration( $ids ) {
$post_ids = get_posts( array(
'post_type' => 'any',
'fields' => 'ids',
'nopaing' => true,
'meta_query' => array(
array(
'key' => 'exclude_local_search',
'type' => 'BINARY',
'value' => true,
),
),
) );
if ( ! empty( $post_ids ) ) {
$ids = array_values(
array_unique(
array_merge( (array) $ids, $post_ids )
)
);
}
return $ids;
}
add_filter( 'searchwp_prevent_indexing', 'my_searchwp_seo_framework_integration' );
add_filter( 'searchwp_exclude', 'my_searchwp_seo_framework_integration' );
view raw functions.php hosted with ❤ by GitHub
Fix Search on Your Site. No Coding Required!

Now you can utilize all of the content that's gone unrecognized by native WordPress search instantly with SearchWP

Get SearchWP