WordPress.org

Forums

[resolved] How to keep adsense robots from viewing comments (5 posts)

  1. Phishie
    Member
    Posted 8 years ago #

    Hello,
    I would like to keep adsense robots from crawling post comments. I know I would use the following code:

    <!-- google_ad_section_start(weight=ignore) -->
    Comments section here
    <!-- google_ad_section_end -->

    but I do not know where to place the code.

    Any help is appreciated.

    Thank you.

  2. Place it in your template, around the comments section. I can't be more specific, you have to look at your template and figure it out. It's not hard.

  3. Phishie
    Member
    Posted 8 years ago #

    domain.com/wp-content/themes/vistered-little-1.6a/comments.php

    One of the divs in the file is:

    <div class="blog">
    <h3><?php comment_author_link(); ?></h3>
    <p class="headertext"><?php comment_type(); ?> on <?php comment_time('F jS, Y'); ?>. <?php edit_comment_link('e', '', ''); ?></p>
    <?php comment_text(); ?>
    </div>

    so I believe I have the right file. Please correct me if I am wrong or let me know if I am right.

    I added <!-- google_ad_section_start(weight=ignore) --> on the first line of comments.php and <!-- google_ad_section_end --> on the last line of comments.php

    That should work, right?

    Thanks in advance.

  4. That might work, but probably the better way is to put those in the single.php file, around the PHP call to comments_template().

    Again, without looking at it, it's difficult to say what's best. You'll just have to figure it out. :)

  5. Phishie
    Member
    Posted 8 years ago #

    Thanks, that worked. I opened up single.php (except it was called index.php with my template) and I made the modifications as follows:

    <!-- google_ad_section_start(weight=ignore) -->
    <?php comments_template(); ?>
    <!-- google_ad_section_end -->

    It's working now. I can see it in my site's source.

    Thanks for the help.

Topic Closed

This topic has been closed to new replies.

About this Topic