Created
December 25, 2025 22:06
-
-
Save lunule/883b80d91f0bc8990b676ee910034e47 to your computer and use it in GitHub Desktop.
[Rank Math - Query Pages Set to Noindex] #query #wp #rank-math #noindex
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?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