• 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 5 replies - 31 through 35 (of 35 total)
  • Right I have scrapped the Nicasio Dynamic header for now and am attempting to use the featured image to display a header image.

    I have got it to work on my pages, yet, it still doesn’t work for my news page (posts page)!!

    See header.php

    See functions.php

    This is frustrating! Please can somebody please help!

    I have also tried

    <?php
    
    $HEADER_IMAGE_WIDTH = 940;
    $HEADER_IMAGE_HEIGHT = 203;
    
    // Check if this is a post or page, if it has a thumbnail, and if it's a big one<br />
    if ( ( is_singular() || is_home() ) && has_post_thumbnail( $post->ID ) && ( /* $src, $width, $height */ $image = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ), 'post-thumbnails-header' ) ) && $image[1] >= $HEADER_IMAGE_WIDTH ) :
    
    //new header image<br />
    echo get_the_post_thumbnail( $post->ID, 'post-thumbnails-header' );
    else : ?>
    <img src="<?php bloginfo('stylesheet_directory'); ?>/images/logo.jpg" width="<?php echo $HEADER_IMAGE_WIDTH; ?>" height="<?php echo $HEADER_IMAGE_HEIGHT; ?>" alt="" />
    
    <?php endif; ?>

    using is_home() in above if condition and still no luck!

    That’s not how you set up – or overwrite – a header image’s width & height. Have you looked at how Twenty Eleven handles this?

    No I haven’t, to be honest I’m no wordpress guru I have only been using it for 9 months now still getting my head around it!

    I suggest that you start by looking at Twenty Elevens header.php and its functions.php file – specifically the twentyeleven_setup() function.

    Thanks

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