• I apologive in advance if this has been answered somewhere but I’m stuggling with poor Google search results on my site. Since my sidebar contains the tag cloud and most recent images grid (wpg2), that’s a fair amount of terms that appear on every single page. Is there an easy way to hide the sidebar from search engines?

    Thanks,
    tim

Viewing 3 replies - 1 through 3 (of 3 total)
  • Thread Starter ts_mpls

    (@ts_mpls)

    Anyone?

    This code has not been tested and may / may not work exactly as you need but this is mearly so you can get started. I would advice to just do it around parts to remove bits in the sidebar rather then remove the whole sidebar. There may be some format issue in the code below due to bbPress but the code below should get you started.

    <?php
    $AreWeGoogle = $_SERVER['HTTP_USER_AGENT'];
    
    if ( $AreWeGoogle == "Googlebot/1.0 ([email protected] https://googlebot.com/) " ) {
    // This is what Google would see. Leaving it blank means nothing is seen.
    }else{
    // Whatever you never wanted Google to see
    }
    ?>

    My example only works with Google, but you can adapt for others.

    Thread Starter ts_mpls

    (@ts_mpls)

    Thanks! At least in K2, it looked like sidebar.php already had a big if wrapper around whole thing, I just added some logic above it. I’m not a PHP guy so the code might be ugly but this seems to be working:

    <?php /* TAS - 5/3/10 */
      $isBot = strstr($_SERVER['HTTP_USER_AGENT'], 'https://www.google.com/bot.html') ||
        strstr($_SERVER['HTTP_USER_AGENT'], 'https://help.yahoo.com/help/us/ysearch/slurp') ||
        strstr($_SERVER['HTTP_USER_AGENT'], 'https://search.msn.com/msnbot.htm') ||
        strstr($_SERVER['HTTP_USER_AGENT'], 'https://sp.ask.com/docs/about/tech_crawling.html');
    ?>
    
    <?php if ( ! $isBot && ! get_post_custom_values('hidesidebar1') ): ?>
Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Hide sidebar from crawlers?’ is closed to new replies.