• Resolved ianbee

    (@ianbee)


    I currently have a different header image for each page on a site I’m working on. I did this with php and also a wordpress plugin called dynamic headers. I used php coding like so:

    <?php if(  is_page(array('bio','videos','photos','events','sponsors','store',))  ){ ?>
    <div id="slideshow">
        <div id="slidesContainer">
          <div class="slide">
    <?php if(function_exists('show_media_header')){ show_media_header(); } ?>
    </div>
    </div>
    </div>
    <?php } ?>

    So this is telling wordpress to use the custom header (show_media header) whenever you are on the bio, videos, photos, events, sponsors, or store pages. I also have this code:

    <?php if( is_404() || is_front_page()   ||
    is_category( array( 912, 'uncategorized', 'articles' ) )  || comments_open() || is_search()    ){ ?>
    Content, content, content, content etc.
    <?php } ?>

    This is telling wordpress that when its on the front page, pages with comments, search pages, 404 page to use the content I posted within the code.

    Now, all of this worked fine, there were separate headers for each page, for every other page there was a slideshow header. Just recently, I changed my blog so the mainpage is a static page and the posts page is set to my news page. The front mainpage has the slideshow images, which I want. Then the blog page (news) is the exact same as the front page, when it should be a seperate image that I assigned to it. I tried to fix it so the blog news page shows up as a different header image like all the other pages, but it did not work.

    Here’s what I tried to do to fix it:
    I added ‘news’ and even is_home() to my php code that tells wordpress to have its own header for each page:
    <?php if( is_page(array(‘news’,’bio’,’videos’,’photos’,’events’,’sponsors’,’store’,)) || is_home() ){ ?>

    When I add the is_home code, the header breaks, nothing happens when I add the ‘news’ to the is_page array. So I’m pretty confident the is_home is the correct coding. But for some reason, the slideshow header is showing up on the news page when it shouldn’t. The news page should show its own header.

    If anyone has any idea of what to do, please help me! It would honestly mean the world ??

Viewing 15 replies - 16 through 30 (of 35 total)
  • Does your theme use the body_class() function on the <body> tag? Try looking in the header.php file

    Yes it does…

    [ 459 lines of code moderated, that’s just way too much. For that many lines of code please use pastebin.com instead. ]

    For starters, get rid if:

    <div style=' clear: both; text-align:center; position: relative;'>
    
        	<a href="https://www.microsoft.com/windows/internet-explorer/default.aspx?ocid=ie6_countdown_bannercode"><img src="https://storage.ie6countdown.com/assets/100/images/banners/warning_bar_0000_us.jpg" border="0" alt="" /></a>
    
        </div>

    That markup should never be in the <head>1 section of a web page. And everything afterwp_head();but before</head>should be moved so that it's <strong>before</strong>wp_head();`.

    That is currently one seriously messed up page head section.

    below is header.php with your suggested code…

    [ 469 lines of code moderated, that’s just way too much. For that many lines of code please use pastebin.com instead. ]

    Is this in the correct place?

    Can you use a pastebin, please?

    Yes sorry. give me 2 minutes…

    Please see header.php with your suggested code (is_home())

    All custom page header were removed!

    Also, how do I get rid of the above? Forgive me I am a ‘noob’

    Ok I moved everything after wp_head(); but before </head> before wp_head();.

    Regarding

    <div style=' clear: both; text-align:center; position: relative;'>
    
        	<a href="https://www.microsoft.com/windows/internet-explorer/default.aspx?ocid=ie6_countdown_bannercode"><img src="https://storage.ie6countdown.com/assets/100/images/banners/warning_bar_0000_us.jpg" border="0" alt="" /></a>
    
        </div>

    How do I remove and what is it?

    https://pastebin.com/7m6ThcFX is a little better – although I still think all of that javascript needs moving out in favour of being enqueued correctly.

    I really appreciate your help on this thanks!

    I implemented your ‘cleaned up’ version of header.php and now the slider on my homepage doesn’t work. Menu items on my top navigation bar no longer work! AHHHH!

    And Post page header image still doesn’t show.

    Ahh I see where

    <div style=' clear: both; text-align:center; position: relative;'>
    
        	<a href="https://www.microsoft.com/windows/internet-explorer/default.aspx?ocid=ie6_countdown_bannercode"><img src="https://storage.ie6countdown.com/assets/100/images/banners/warning_bar_0000_us.jpg" border="0" alt="" /></a>
    
        </div>

    it wasn’t picked up in find and replace in dreamweaver as it was commented out!

    Any ideas about the slider and menu nav not working?

    Is this a Javascript problem why my Menu bar and Slider isn’t working?

    I have changed header.php back to original code as these were working!

    Is this a Javascript problem why my Menu bar and Slider isn’t working?

    It’s certainly possible. I can’t see any other reason why is_home() isn’t working correctly.

    I just used

    <?php if( is_home() ) { ?>
        <p>is home is working!</p>
    <?php } ?>

    and it printed on Posts page so it seems to be working…perhaps the problem is within the Nicasio dynamic header plugin itself?

Viewing 15 replies - 16 through 30 (of 35 total)
  • The topic ‘is_home() breaking posts page’ is closed to new replies.