Add Custom Noindex Meta

With Squirrly SEO plugin you can customize the META Robots for each URL on your website using the Squirrly SEO SnippetSquirrly > SEO Settings > Automation or by calling the sq_noindex hook in your code.

To edit the META Robots using the SEO Automation follow the instructions from this URL: 
https://howto.squirrly.co/kb/bulk-seo/#bulk_seo_visibility

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 above code 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.

How to customize the META Noindex using the Squirrly SEO plugin:
https://howto.squirrly.co/kb/bulk-seo/#bulk_seo_visibility

Was This Article Helpful?

Related Articles
0 Comments

There are no comments yet

Leave a comment

Your email address will not be published. Required fields are marked *