WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] is_home() breaking posts page (36 posts)

  1. ianbee
    Member
    Posted 1 year ago #

    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 :)

  2. deepbevel
    Member
    Posted 1 year ago #

    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.

  3. ianbee
    Member
    Posted 1 year ago #

    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. :)

  4. deepbevel
    Member
    Posted 1 year ago #

    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.

  5. deepbevel
    Member
    Posted 1 year ago #

    the slider may think "is_home" means "is your blog page", even if it's not the home page.

  6. ianbee
    Member
    Posted 1 year ago #

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

  7. adsleeblythe
    Member
    Posted 1 year ago #

    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

  8. deepbevel
    Member
    Posted 1 year ago #

    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.

  9. adsleeblythe
    Member
    Posted 1 year ago #

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

  10. adsleeblythe
    Member
    Posted 1 year ago #

    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!

  11. esmi
    Forum Moderator
    Posted 1 year ago #

    For the main posts page, try:

    <?php if( is_home() ) { ?>
    			  <?php if(function_exists('show_media_header')){ show_media_header(); } ?>
    			<?php } ?>
  12. adsleeblythe
    Member
    Posted 1 year ago #

    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

  13. esmi
    Forum Moderator
    Posted 1 year ago #

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

  14. adsleeblythe
    Member
    Posted 1 year ago #

    Very sure!

    Take a look!

  15. esmi
    Forum Moderator
    Posted 1 year ago #

    Site url?

  16. adsleeblythe
    Member
    Posted 1 year ago #

  17. esmi
    Forum Moderator
    Posted 1 year ago #

    Does your theme use the body_class() function on the <body> tag? Try looking in the header.php file

  18. adsleeblythe
    Member
    Posted 1 year ago #

    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. ]

  19. esmi
    Forum Moderator
    Posted 1 year ago #

    For starters, get rid if:

    <div style=' clear: both; text-align:center; position: relative;'>
    
        	<a href="http://www.microsoft.com/windows/internet-explorer/default.aspx?ocid=ie6_countdown_bannercode"><img src="http://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.

  20. adsleeblythe
    Member
    Posted 1 year ago #

    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?

  21. esmi
    Forum Moderator
    Posted 1 year ago #

    Can you use a pastebin, please?

  22. adsleeblythe
    Member
    Posted 1 year ago #

    Yes sorry. give me 2 minutes...

  23. adsleeblythe
    Member
    Posted 1 year ago #

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

    All custom page header were removed!

  24. adsleeblythe
    Member
    Posted 1 year ago #

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

  25. adsleeblythe
    Member
    Posted 1 year ago #

    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="http://www.microsoft.com/windows/internet-explorer/default.aspx?ocid=ie6_countdown_bannercode"><img src="http://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?

  26. esmi
    Forum Moderator
    Posted 1 year ago #

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

  27. adsleeblythe
    Member
    Posted 1 year ago #

    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.

  28. adsleeblythe
    Member
    Posted 1 year ago #

    Ahh I see where

    <div style=' clear: both; text-align:center; position: relative;'>
    
        	<a href="http://www.microsoft.com/windows/internet-explorer/default.aspx?ocid=ie6_countdown_bannercode"><img src="http://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?

  29. adsleeblythe
    Member
    Posted 1 year ago #

    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!

  30. esmi
    Forum Moderator
    Posted 1 year ago #

    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.

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.