WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] How to put noindex on category PAGES? (5 posts)

  1. RedPitbull
    Member
    Posted 1 year ago #

    I want to put noindex atribute on category pages. With other words, I need the category indexed, but category/page-1 with no index.

  2. keesiemeijer
    moderator
    Posted 1 year ago #

    try it with this in your theme's functions:

    add_action('wp_head', 'add_meta_paged_category_pages');
    function add_meta_paged_category_pages(){
    	if(is_category() && is_paged()) {
    		echo '<meta name="robots" content="noindex, follow">';
    	}
    }
  3. RedPitbull
    Member
    Posted 1 year ago #

    Thank you for your reply.
    I put it and got this error: Parse error: syntax error, unexpected T_FUNCTION, expecting T_STRING or T_VARIABLE or '$' in http://....

  4. keesiemeijer
    moderator
    Posted 1 year ago #

    That's strange, if I use it I get no errors.

    Can you post the content of your functions.php (with my code in it) here. See the Forum Rules on how to post code.

  5. RedPitbull
    Member
    Posted 1 year ago #

    I just had to put a ; somewhere. Now is working like perfectly.
    Thank you a lot for your help!

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.