0

From an SEO perspective, i'm trying to add conditional title tags to my WP theme such that it echos a piece of text based on various categories.

Assuming that my category id's are 1, 2, 3, 4

Then i'd like to add Title 1 if category id = 1, title 2 if category id = 2 and so on.

Could someone assist in the correct php syntax to implement this.

Thanks.

  • Correct me if I'm wrong, when user is viewing post that's in category with id = 1 you want to echo some specific title? – Mamaduka Aug 23 '11 at 17:00
  • Yep. If Category 1 (which is let's call it news) is clicked on, then the title would show "This is the news category" (without the quotes of course) – Sledge81 Aug 23 '11 at 17:18
0

See codex page for category conditional tags - http://codex.wordpress.org/Conditional_Tags#A_Category_Page

You can use them like so:

<title>
<?php 
if ( is_category( '1' ) )
   echo 'This is the news category';
?>
</title>

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.