0

Hi i have this code below in my header file

<?php
if ( ! is_home() ) {

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>';
}
if ( get_post_type() == 'revenge' ) {
    echo '<div id="headerimg"><img  src="http://tv-cafe.com/wp-content/uploads/2012/08/revenge.png"></div>';
}
if ( is_tax( 'series', 'pretty-little-liars' ) ) $stylesheet_uri = $stylesheet_dir_uri . 'http://www.tv-cafe.com/wp-content/themes/tvcafe/posttypecss/style-pll.css';
}
?>

The first three "if" lines calls for a different header image which works properly, but the fourth "if" line i was trying to call for a different stylesheet for a Taxonomy term.

I have a post type entitled gallery, and under the gallery post type i have the Taxonomy "Series" and one of the terms happens to be "pretty-little-liars".

Here is what i want. Whenever a user click on a gallery post and it's under the Taxonomy Term "pretty-little-liars" I want it to have a different background image. The above code doesn't work for the taxonomy so what am i doing wrong or how do i fix this, suggestions anyone? I would really appreciate the help :)

1

is_tax() is a check for taxonomy archive page and as I understand you want this for individual posts. The function to use would be has_term():

if ( has_term( 'pretty-little-liars', 'series' ) )

Also it's good practice to enqueue style properly via wp_enqueue_style().

  • Thanks, you i just tried that but the styleshett still didn't change, here is what i have, is there anything else that needs to change <?php if ( has_term( 'pretty-little-liars', 'series' ) ) $stylesheet_uri = $stylesheet_dir_uri . 'http://www.tv-cafe.com/wp-content/themes/tvcafe/posttypecss/style-pll.css'; } ?> – Terrell Anderson Aug 20 '12 at 22:53
0

I finally made it work thank goodness, here is the code.

<?php
if ( ! is_home() ) {

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>';
}
if ( get_post_type() == 'revenge' ) {
    echo '<div id="headerimg"><img  src="http://tv-cafe.com/wp-content/uploads/2012/08/revenge.png"></div>';
}
if( has_term( 'pretty-little-liars', 'series' ) ) {
echo '<link rel="stylesheet" href="http://www.tv-cafe.com/wp-content/themes/tvcafe/posttypecss/style-pll.css" type="text/css" media="screen" />', '<div id="headerimg"><img  src="http://tv-cafe.com/wp-content/uploads/2012/08/liars.png"></div>';

}
}
?>

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.