WordPress.org

Ready to get started?Download WordPress

Forums

"Different Headers" Code Breaks in Safari (4 posts)

  1. Velanche
    Member
    Posted 7 years ago #

    Hello:
    I'm trying to get some last-minute gaps out of the way with regards to the modification of the code that jberglund created that shows a different header based on category.

    Here's the code, located in the header.php file...


    <style type="text/css" media="screen">
    /* Calls the style sheets for each category */
    <?php
    $post = $wp_query->post;
    if (is_home()) {
    include(TEMPLATEPATH . '/style.css');
    } elseif ( in_category('1') ) {
    include(TEMPLATEPATH . '/cat-news.css');
    } elseif ( in_category('2') ) {
    include(TEMPLATEPATH . '/cat-reviews.css');
    } elseif ( in_category('8') ) {
    include(TEMPLATEPATH . '/cat-charts.css');
    } elseif ( in_category('9') ) {
    include(TEMPLATEPATH . '/cat-playlists.css');
    } elseif ( in_category('12') ) {
    include(TEMPLATEPATH . '/cat-podcasts.css');
    } else {
    include(TEMPLATEPATH . '/style.css');
    }
    ?>
    </style>

    <?php /* Calls the header image for each category - necessary code */
    $post = $wp_query->post;
    if (is_home()) {
    $imgurl = "images/ul-banner.png";
    } elseif ( is_page() ) {
    $imgurl = "images/ul-banner.png";
    } elseif ( in_category('1') ) {
    $imgurl = "images/ul-cat-news.png";
    } elseif ( in_category('2') ) {
    $imgurl = "images/ul-cat-reviews.png";
    } elseif ( in_category('8') ) {
    $imgurl = "images/ul-cat-charts.png";
    } elseif ( in_category('9') ) {
    $imgurl = "images/ul-cat-playlists.png";
    } elseif ( in_category('12') ) {
    $imgurl = "images/ul-cat-podcasts.png";
    } else {
    $imgurl = "images/ul-banner.png";
    }
    ?>
    <style type="text/css" media="screen">
    /* Disable the header style in the individual style sheets and embed it here. */
    #header {
    background: url(<?php bloginfo('stylesheet_directory') ?>/<?php echo $imgurl; ?>);
    height: 145px;
    background-color: #FFFFF0;
    </style>

    A sample of the header section of one of the category css files:


    #header {
    background: url('images/ul-cat-news.png') no-repeat;
    height: 145px;
    background-color: #FFFFF0;
    }

    My immediate problem is that whenever I choose a "Page" or "category" link, the solid background appears but the image does not.

    In addition, I'd like to also include conditions for bringing up a different banner based on the page in question, in addition to the categories. So far, no luck.

    I plan to launch the site within the next few days, so I'd appreciate any help that can be offered. Thanks!
    Velanche

  2. PozHonks
    Member
    Posted 7 years ago #

    <style type="text/css" media="screen">
    /* Disable the header style in the individual style sheets and embed it here. */
    #header {
    background: url(<?php bloginfo('stylesheet_directory') ?>/<?php echo $imgurl; ?>);
    height: 145px;
    background-color: #FFFFF0;
    </style>

    Found 2 errors. It misses the } at the end But maybe it's a typo?
    In the url() command, it misses the apostrophes, like url('blah').

  3. Velanche
    Member
    Posted 7 years ago #

    Well it's always the simple things, aren't they?!

    Thanks a bunch...that did the trick!

    Not sure yet about what happens when I add "pages" to the code, but I'll try that tomorrow.

    Velanche

  4. action13
    Member
    Posted 7 years ago #

    Hey Velanche,

    Did you find the code for the pages ? Could you reply it to me ? Thanks,

Topic Closed

This topic has been closed to new replies.

About this Topic