How to I noindex attachments

Community Forums Forums General Discussion How to I noindex attachments

This topic is: not resolved

This topic contains 1 reply, has 2 voices, and was last updated by  braddalton 11 months, 1 week ago.

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #41518

    nicole2013
    Participant
    Post count: 28

    I need to no index attachments. I used Yoast’s plugin to do this but I see that they are still being indexed.

    I have recently moved from thesis. On Thesis I used the following code but I don’t know how to adapt it for Genesis:
    /*noindex_attachments*/

    function noindex_attachments() {

        if (is_attachment())

            echo ‘<meta name=”robots” content=”noindex” />’;

    }

    add_action(‘wp_head’,'noindex_attachments’);

    http://www.yetzira.com
    #41548

    braddalton
    Participant
    Post count: 7467

    Should also work in any theme because it uses the wp_head hook which is a WordPress hook and not a theme specific hook.

    Paste it at the end of your child themes functions.php file.

    Note: I wouldn’t copy and paste it from here because it hasn’t been embedded properly which can cause the Apostrophes to change and cause errors.


    WordPress Developer & Consultant
    Brad Dalton400+ StudioPress Tutorials & 1200+ Code snippets

Viewing 2 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic.