Skip to content Skip to main navigation Skip to footer

Add Custom Noindex Meta

With Squirrly SEO plugin you can customize the META Robots for each URL on your website using the:

  •  Squirrly SEO Snippet
This image has an empty alt attribute; its file name is noindex-meta.jpg
  • Squirrly SEO > Automation > Configuration 
  • or by calling the sq_noindex hook in your code.

To edit the META Robots using the SEO Automation follow the instructions detailed here >>  
To edit the META Robots using the  sq_noindex hook, activate Squirrly SEO plugin and add this code in function.php file:

//Hook the Squirrly sq_noindex
add_filter('sq_noindex', 'custom_squirrly_noindex', 11);
function custom_squirrly_noindex($robots) {
    $robots = array();
    
    $robots[] = 'index'; //or noindex of you don't want the page to be indexed
    $robots[] = 'follow'; //or nofollow of you don't want the page to receive authority
    
    return $robots;
}

The code above will add the robots index and follow for Google to index and follow all the pages on your website.

If you want to change the robots only for some post IDs you can add the hook like:

//Hook the Squirrly sq_noindex for post_ids
add_filter('sq_noindex', 'custom_squirrly_noindex', 11);
function custom_squirrly_noindex($robots) {
    $robots = array();

    global $post;
    switch ($post->ID) {
        case 1:
            $robots[] = 'index';
            $robots[] = 'follow';
        case 2:
            $robots[] = 'noindex';
            $robots[] = 'nofollow';
    }

    return $robots;
}

Just change the posts 1 and 2 with your post_ids. You can add more cases for more posts ids.

Learn how to customize the META Noindex using the Squirrly SEO plugin >>

Was This Article Helpful?