Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

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.

share|improve this question
    
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
add comment

1 Answer

up vote 0 down vote accepted

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>
share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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