• Resolved indiaberry

    (@indiaberry)


    How do I prevent google from reading comments on my website? I don’t mind google listing my site. I post an uncommon name on my website, and google track that word directly to my website. And since then, when I put that word in the google search, it come directly to my website. How do I keep google from reading my comment?

Viewing 12 replies - 1 through 12 (of 12 total)
  • The ONLY way you can do that is by checking the user-agent and hiding content based on the user-agent.

    Here’s something to get your brain in thinking mode:

    $useragent = $_SERVER['HTTP_USER_AGENT'];
    $google = "Googlebot";
    $isgoogle = strpos($useragent, $google);
    If ($isgoogle === false) {
    //not a Google hit
    } else {
    //This is Google
    Thread Starter indiaberry

    (@indiaberry)

    Where should I put that code?

    “Here’s something to get your brain in thinking mode”

    Doesnt sound like youre thinking, sounds like you want someone to do this for you?

    Thread Starter indiaberry

    (@indiaberry)

    Should it go in the .htaccess file? Does it go in the index.php of the theme? Could I have a little more hint?

    That is php code. It can go in one of two places

    1. index.php, page.php, single.php, etc before the comment code

    2. start of comment.php

    I’d pick 2 because it involves changing only 1 file.

    Thread Starter indiaberry

    (@indiaberry)

    Hi! When I tried the code, the words show up on the page. How do I insert the code. I know how to edit a file. But what I don’t know is if I need to put the code in this <php ?>

    Thread Starter indiaberry

    (@indiaberry)

    It is just that I put that code in the comment.php, it show up on the page of where the comments are. I am wondering what is the best way to insert the code?

    Thread Starter indiaberry

    (@indiaberry)

    I need a bit more help with this code, please.

    Put it all inside <? php ?> tags and tbh I haven’t looked into it but if theres something like include(comments.php) then put the comments include in the // not a google hit. Oh, and I’m not a php coder but it’s something like that ^^

    Adam

    Thread Starter indiaberry

    (@indiaberry)

    When I put this in:
    <?php $useragent = $_SERVER[‘HTTP_USER_AGENT’];
    $google = “Googlebot”;
    $isgoogle = strpos($useragent, $google);
    If ($isgoogle === false) {
    //not a Google hit
    } else {
    //This is Google
    ?>

    I get:
    Parse error: syntax error, unexpected $end in /home/domainname/public_html/writer/wp-content/themes/girl/comments.php on line 113

    <?php $useragent = $_SERVER['HTTP_USER_AGENT'];
    $google = "Googlebot";
    $isgoogle = strpos($useragent, $google);
    If ($isgoogle === false) {
    //not a Google hit
    } else {
    //This is Google
    }
    ?>

    Missing closing bracket.

    Thread Starter indiaberry

    (@indiaberry)

    Thank you. I was having a hard time figuring out what went wrong. From now on, I will include the closing bracket. Topic solved.

Viewing 12 replies - 1 through 12 (of 12 total)
  • The topic ‘Prevent google from reading comment…’ is closed to new replies.