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.

Is there a code that i can place in the header that will call a certain div and the content i place inside it for every custom post type i have, Somthething like this.

 <?php if (is_post_type('pretty-little-liars') ) {echo '<div id="headerimg"><img src="http://tv-cafe.com/wp-content/uploads/2012/08/liars.png"></div>'; } ?>

I know that the code above doesn't work, but is there a way that i can call something like that for each post type i have, i will be placing this code in the header.

Also if anyone does have the solution could you please tell me where do i add a second line to the code that repeats the first line but with a different post type name?

share|improve this question

1 Answer 1

up vote 1 down vote accepted

I think that will only work in the loop, but what you can do outside of the loop is use

<?php
if (get_post_type() == 'pretty-little-liars') {
echo '<div id="headerimg"><img src="http://tv-cafe.com/wp-content/uploads/2012/08/liars.png"></div>'; 
} 
?>
share|improve this answer
    
Thank you that works.....but how do i add a second line –  Terrell Anderson Aug 3 '12 at 1:01
    
When i create a second one it shows in the home page :( –  Terrell Anderson Aug 3 '12 at 3:06

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.