Skip to content

Instantly share code, notes, and snippets.

@jchristopher
Created July 8, 2019 17:55
Show Gist options
  • Save jchristopher/a9388c60721c0204fc14614c7050f722 to your computer and use it in GitHub Desktop.
Save jchristopher/a9388c60721c0204fc14614c7050f722 to your computer and use it in GitHub Desktop.
Integrate SearchWP with SEO Framework local search exclusion
<?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' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment