skip to Main Content

I’m referring to specific product not all products. I’ve googled and can’t find any answer to this.

2

Answers


  1. there are a few solutions, maybe you’d like to use meta tags noindex. It would be something like this:

    function product_robots_noindex_meta_tags() {
        global $product;
        $no_robots_products = array(12,13,14); // list of product ids
        if ( $product && in_array($product->get_id(), $no_robots_products) ) {
            echo '<meta name="robots" content="noindex" />';
        }
    }
    add_action('wp_head', 'product_robots_noindex_meta_tags');
    
    Login or Signup to reply.
  2. There are many ways to skin a cat.

    You can use the Robot.txt.

    You can disallow a certians URLs:

    User-agent: *
    Disallow: /wp-admin/
    Disallow: /wp-includes/
    

    Or certains file type:

    User-agent: *
    Disallow: /pdfs/ # Block the /pdfs/directory.
    Disallow: *.pdf$  # Block pdf files from all bots. Albeit non-standard, it works for major search engines.
    

    Or images:

    User-agent: Googlebot-Image
    Disallow: /images/cats.jpg #Block cats.jpg image for Googlebot specifically.
    

    Or Gifs:

    User-agent: Googlebot-Image
    Disallow: /*.gif$
    

    You can use PHP:

    Paste this between <head> and </head> if you want to disallow a certain post (change “ID” with your post ID), (You have tons of plugins that can help you customise the Header without need of codeing):

    <?php if ($post->ID == X) { echo '<meta name="robots" content="noindex,nofollow">'; } ?>
    

    You can even block multiple ones using the || operator:

    <?php if ($post->ID == X || $post->ID == Y) { echo '<meta name="robots" content="noindex,nofollow">'; } ?>
    

    Or you can block a certain post title:

    <?php if(is_single('Hello World')): ?>
    

    Multiple post title, always using the || operator:

    <?php if ( is_single('big-announcement') || is_single('new-update-coming-soon') ) ) : ?>
    

    After you applied the change:

    After you applied the change wait a few days. Then go to Google Webmaster and check what pages are indexed and what are not indexed.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search