Site logo

[Resolved] How to use Noindex, Nofollow Metatags in Custom Template Page

Home Forums Support [Resolved] How to use Noindex, Nofollow Metatags in Custom Template Page

Home Forums Support How to use Noindex, Nofollow Metatags in Custom Template Page

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #2503117
    Ashia

    Hello,
    I am using a custom template, located in the GeneratePress Child theme folder. I am using this template for some specific posts using the Hook function, here are the codes I am using for the template, thanks to GeneratePress support for helping with making the template, https://generatepress.com/forums/topic/i-want-to-show-element-block-content-template-into-a-custom_template-php/#post-2492620

    I want to use Noindex, and Nofollow meta tags for the template, or for the posts using this template. using robots.txt might help from not indexing, but I also want to make sure all links on the posts are nofollow.

    #2503322
    David
    Staff
    Customer Support

    Hi there,

    you could include it in your Custom Template.
    Change this:

    get_header(); 
    ?>

    to:

    get_header(); 
    add_action('wp_head', function(){echo '<meta name="robots" content="noindex">';});
    ?>
    

    To cover, the get_header() function loads the themes header.php and that includes the wp_head hook.
    So after the get_header() is called we can hook the meta tag into the wp_head

    #2504166
    Ashia

    Thanks David

    #2504197
    David
    Staff
    Customer Support

    You’re welcome

Viewing 4 posts - 1 through 4 (of 4 total)
  • You must be logged in to reply to this topic.