Support » Fixing WordPress » is_home() breaking posts page

  • 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 - 1 through 15 (of 35 total)
  • i think is_home may only work if the home page is the blog page, and is_front_page if static. Or, maybe try it with page id’s instead of page names.

    i think is_home may only work if the home page is the blog page, and is_front_page if static. Or, maybe try it with page id’s instead of page names.

    Thanks for the feedback! My homepage is the blogpage and the frontpage is a static page. I tried doing what you said and entering the blog page’s ID instead of the page’s name… it did nothing. When I enter the PHP code is_home to change my header so it is different on the homepage, it breaks my header. With any other php code, it does nothing. So I know is_home is the correct coding to change the header on my blog page.

    I don’t get why the slideshow header is showing up on my main blog page, when I’m telling it not to. But again, when I tell it to show a custom header for the page ( is_home )… the header breaks, and you can still see the slideshow header, when you shouldn’t be able to.

    I hope that makes sense, and again, any help would be appreciated so much. If I’m not explaining myself fully or you don’t understand, please let me know and I will gladly try to help you understand. 🙂

    Just to make sure I understand, are you refering to your main blog page with the code “is_home”
    ?
    if so, it won’t work, because I think you said your home page is static. So, you would have to use “is_front_page” instead of “is_home”.
    however this is just a shot of course, could possibly be something not even related to your coding.

    the slider may think “is_home” means “is your blog page”, even if it’s not the home page.

    Thanks for the help, I found out how to fix this issue, sort of. Will explain later 🙂 Thanks doe! 😀

    Ianbee,

    I would like to know how you fixed this!

    I’m having the same problem. I am using the Nicasio Dynamic Header plugin to insert custom header images to my pages which work fine. I created a ‘News’ page and set it to show my posts (Posts page: News under settings – reading), and the Nicasio Dynamic Header doesn’t work!

    Any thoughts?

    Thanks

    ianbee added conditional code to determin where the slider shows up. Are you doing the same? I don’t think the issue was with the slider, but the conditions.

    Ok, I will try using the conditions. Forgive me, but should this go in functions.php??

    I tried the following in header.php

    <?php if( is_page() ) { ?>
    			  <?php if(function_exists('show_media_header')){ show_media_header(); } ?>
    			<?php } ?>

    Header images remained visible on all pages but still not on my Posts Page! Frustrating!

    esmi

    (@esmi)

    Forum Moderator

    For the main posts page, try:

    <?php if( is_home() ) { ?>
    			  <?php if(function_exists('show_media_header')){ show_media_header(); } ?>
    			<?php } ?>

    thanks esmi, I tried the above in header.php and it removed ALL custom page headers from my pages!

    have I put the code in the right template file?

    Thanks

    esmi

    (@esmi)

    Forum Moderator

    Are you sure that the News page is set as your main posts page in Settings -> Reading?

    Very sure!

    Take a look!

    esmi

    (@esmi)

    Forum Moderator

    Site url?

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