WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] Calling wrong Header.php file? (3 posts)

  1. aliceralph
    Member
    Posted 2 years ago #

    Hello

    This has completely baffled me for the last day.

    I am building on a localhost and then using Subversion (Cornerstone & Deploy) to upload to my Dev site.

    For my posts/single.php I am using the following code in the header to call different headers:

    <?php
    if ( has_post_thumbnail()) {
    get_header('Single');
    } else {
    get_header('Inner');
    }
    ?>

    Basically I have two custom headers, 'Inner' and 'Single'. 'Single' displays the Featured Image within the header. If there isn't a Featured Image then it defaults to the 'Inner' custom header which displays a default header for all internal pages (which is different to header.php, which I only use on the homepage...!) Everyone keeping up? ;)

    So the bit of code above checks whether the post has a Featured Image or not. If it does then it uses 'Single', if not it uses 'Inner'.

    This works absolutely fine on my localhost build! Hurrah!

    HOWEVER (here's the twist...)

    ...when I deploy it to my Dev site, it doesn't use either 'Single' or 'Inner'. It defaults to header.php. I am only using header.php on the home page as it has a slideshow plugin built into it. I have double checked via FTP and it using the exact same files as my localhost (incl the same version of single.php). I have tried clearing caches and using different browsers, even different computers.

    This is so weird as the only thing that has changed is the hosting server and the .htaccess (as the Dev directory is password protected). I am using the exact same database and version of WordPress. Could this be PHP 4/5 related? Why would it cause that?

    ANY help very very gratefully received as I am totally stumped!

    Thank-you in advance

    Alice

  2. aliceralph
    Member
    Posted 2 years ago #

    PS. I am using Featured Content Slider plugin in my header.php file. Could that be a culprit?

  3. aliceralph
    Member
    Posted 2 years ago #

    Okay after 2 days I have just fixed this!! *high fives myself*

    If anybody else ever has the same problem... it was actually the bit of code above. I changed it from above to this:

    <?php
    if ( has_post_thumbnail()) {
    include("header-single.php");
    } else {
    include("header-inner.php");
    }
    ?>

    Even though this renders exactly the same on my localhost, it now works on my Dev host. I presume this is a PHP thing that meant it wasn't being read properly for some reason.

    I still have no idea how or why this happened but that was the fix. SO SATISFYING!!!

Topic Closed

This topic has been closed to new replies.

About this Topic