Skip to content

Instantly share code, notes, and snippets.

@lunule
Created December 25, 2025 22:06
Show Gist options
  • Select an option

  • Save lunule/883b80d91f0bc8990b676ee910034e47 to your computer and use it in GitHub Desktop.

Select an option

Save lunule/883b80d91f0bc8990b676ee910034e47 to your computer and use it in GitHub Desktop.
[Rank Math - Query Pages Set to Noindex] #query #wp #rank-math #noindex
<?php
add_action('the_content', function() {
$noindex_pages = new WP_Query( [
'post_type' => 'page',
'post_status'=> array('publish', 'private'),
'meta_query' => [
[
'key' => 'rank_math_robots',
'value' => '"noindex"', // key part: search for serialized string match
'compare' => 'LIKE',
],
],
] );
if ( $noindex_pages->have_posts() ) {
while ( $noindex_pages->have_posts() ) {
$noindex_pages->the_post();
echo get_the_title() . "<br>";
}
}
wp_reset_postdata();
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment