• I need to use different headers, not header images, for the following set up:
    Front page (displays 10 most recent posts) – 1 Header
    Individual posts and pages – A different header (same header though)

    I know how to set up different sidebars for these types of pages by calling for it in the page.php and singlepost.php, but when I try to call for the header-custom.php page in the () I tried listing it as just get_header(‘custom’), like I did with the sidebars and it didn’t work.

    I really need to have this resolved by midnight tonight (April 5th). If anyone can help, I am all ears.

Viewing 7 replies - 1 through 7 (of 7 total)
  • There’s currently no option to call a custom header in the same way that you can a sidebar via template tags. What about using Conditional tags in header.php to either load the image for the front page or default to the main header image elsewhere?

    Thread Starter dougdirt

    (@dougdirt)

    Its not an image that I want to use. I have different ad placements requirements that need to be met. Anything not on the ‘front page’ needs to be a different ad than what is on the ‘front page’. So anything that is https://www.domain.com/specificpost or https://www.domain.com/page need to have a different ad set up than that of the one in the header for simply https://www.domain.com.

    Why not just do some include switching in your header file?

    <?php
    if(is_page('X')) {
    include('somepagetoinclude.php');
    } elseif(is_page('X2')) {
    include('someotherpagetoinclude.php');
    } elseif(is_frontpage()) {
    
    do something for frontpage
    
    } else {
    
    if nothing above is matched then do this etc etc...
    
    }
    ?>

    And so on…

    If you just want to rotate adverts, why include another whole file for it?

    There’s an abundance of rotation scripts no more then a few lines long available for that kind of thing.

    Thread Starter dougdirt

    (@dougdirt)

    t31os,
    That may actually work (haven’t tried it just yet), but do you have any solution on how to tackle it from a single post?

    Its not really a rotation of ads that I need to run. I need specific codes to only show up when its the front page and then a different set of code for anything thats not on the front page (including pages and single posts).

    if(is_single()) { 
    
    this is shown if it's a single post page..
    
    }
    if(is_page()) {
    
    this is shown if it's a page
    
    }
    if(is_front_page()) {
    
    this is shown if it's the front page
    
    }

    Or if you need to check it’s not the front page but is a page or single post, then combine them…

    if(is_single()) { 
    
    this is shown if it's a single post page..
    
    }elseif(is_page()) {
    
    this is shown if it's a page
    
    }elseif(is_front_page()) {
    
    this is shown if it's the front page
    
    }

    Really depends what cases they need to match, lets say you wanted to catch when it’s not the frontpage, not a single post page but anything else…

    if(!is_front_page() && !is_single()) {
    
    It's not the front page or a single post page..
    
    }

    Adding the exclamation ! , is simply like saying NOT…

    Thread Starter dougdirt

    (@dougdirt)

    I found a much easier option.

    Since I already had another ‘header’ page written, rather than start off by ‘get_header’ I simply used ‘include_header1.php’ and it worked. So much easier than writing the loops.

    t31os, thank you for attempting to help though. I appreciate it a ton, even if I went in a different direction.

    If you’re going to use that file as a header.. then use require instead..

    <?php require('yourfilename.php');?>

    or..

    <?php require_once('yourfilename.php');?>

    Ensures pages that should include the header can’t be loaded without it.

    Otherwise i could potentially call your files directly without them including the header page… (not sure if WP would catch it, but just incase).

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘Different headers for posts/front/pages’ is closed to new replies.