• Maracas1970

    (@maracas1970)


    Hello one and all.

    I have created a fairly basic WordPress theme and uploaded it to the Themes directory. So currently i have a folder with style.css index.php, header.php & footer.php no sidebar yet as i only want to use one on my blog page, which hasn’t been uploaded yet.

    The landing page is the only page that i don’t. want the header and footer to appear on

    The problem i’m finding is that no matter how many times i try to write the conditional statements to remove header and footer.php it is never removed. Some code examples:

    My index.

    https://pastebin.com/f3HnBYyw

    My header

    https://pastebin.com/BTCnpsJ4

    My footer

    https://pastebin.com/QS3Ly2wa

    I have tried putting statements in various places, i think my problem apart from being complete novice is i don`t understand which page i need to reference in the if statement.

    I have tried:
    <?php if( !is_page( ‘1’ ) ) : ?> {with various page numbers}

    <?php if( !is_home( ” ) ) : ?>

    <?php if( !is_front_page( ” ) ) : ?>

    Each time i have wrapped this around the code in the header and footer.

    I hope this makes some sense to someone, and i have tried unsuccessfully to rectify this using existing posts.

    Many thanks

    Kark

Viewing 15 replies - 16 through 30 (of 30 total)
  • Peter_L

    (@peter_l)

    No, that goes inside your header.

    Look a basic page looks like this
    header
    the loop
    sidebar
    footer

    Your home page should look like this
    header-home
    the loop (or some static content if you want)
    sidebar
    footer-home (if you want)

    You could just forget about the entire header-home thing, but it’s cleaner, simpler and should spare you from other problems.

    You want a specific header for the home page.
    So, the index.php (home page) gets the specific header header-home.php

    Thread Starter Maracas1970

    (@maracas1970)

    I don’t have a sidebar for the homepage, was only intending to use this for the blog page, is this OK? Or will it cause problems?

    Thread Starter Maracas1970

    (@maracas1970)

    Also when i go to my appearance/editor within WordPress i only see three files. index, footer and header, why dont the other files i created and uploaded to the same directory show here eg: my footer and header home files.

    Also dont have the option in add pages to create new template page..

    Thanks

    Peter_L

    (@peter_l)

    no sidebar is no problem
    the header-home.php should have commenting on the top, same as the header.php but adapted
    That way, Wp recognizes it

    Thread Starter Maracas1970

    (@maracas1970)

    i just have the same commenting as the header.php which is

    <?php
    /**
    * @package WordPress
    * @subpackage BPR
    */
    ?>

    Do i need to include something else in here, this is the same comment that is on all my pages.

    Peter_L

    (@peter_l)

    No, hold on, the commenting shouldn’t matter.
    Just doublechecked it.

    It should be there. Are you sure you uploaded those files + put them next to other template files?

    Thread Starter Maracas1970

    (@maracas1970)

    Oh dear, i thought i was reasonably good at following instructions..

    I have done all the things you said to my knowledge. I will include where i am with header-home and my index.php now. Just incase it`s something obvious.

    the index: https://pastebin.com/Mb0rtJNd

    the header-home: https://pastebin.com/wkKJ3gGn

    Im going for a cup of tea. ??

    Thread Starter Maracas1970

    (@maracas1970)

    Sure they are in my wp-content/themes/bpr/folder

    This is what i keep imagining, that they are simply not there.

    Peter_L

    (@peter_l)

    Omg, I can’t explain worth shit.

    Suppose an html file

    <html>
    <head>some meta</head>
    <body>some text</body>
    </html>

    What wordpress does is
    put the html and head inside the header.php
    most of the body inside the index.php
    the rest inside the footer.php

    So inside your index.php, first thing you do is tell wordpress to get all the things from inside header:
    <?php get_header(); ?>
    next comes the real content, in your case the static content inside id=”home-nav”
    after that is done, tell wordpress to get the footer
    <?php get_footer(); ?>

    What you just did was to put everything inside the custom header file (header-home.php) and then everything inside your index file and just blend it all together.

    I you can’t grasp that you’ll to start WordPress 101.

    Thread Starter Maracas1970

    (@maracas1970)

    OK

    so i have taken all the code out of the header-home.php & header.php files that was not needed, and only included the parts i want to include for the separate pages in the site.

    For example i have included the home navigation code in the header.home.php file, and the homepage image.

    And the code i want to use in the rest of the site in the header.php file, ie, the main site navigation and a banner link/image.

    I have taken the meta out of the index.php as if i understand correctly that`s needed in the header and nowhere else.

    so to reiterate. this is my index.php: https://pastebin.com/6MDfMabe

    this is my header( the one i wish to use for the rest of the site but not on the home page: https://pastebin.com/pMmWajUV

    And finally this is my header-home.php file: the one i want to use only for the homepage: https://pastebin.com/p5FspqXV

    Please tell me i`m not going mad. I am still not getting the other files i have created to be seen within the wordpress appearance/editor either. And still cannot create custom template from the pages menu, simply isnt the option there..

    Peter_L

    (@peter_l)

    It’s better but still some problems

    So, the home page opens the index.php

    Inside the index.php WP encounters this <?php get_header(‘home’); ?>, wich means, go to header-home.php grab everything that’s in there and paste it ‘here’.

    The header-home.php has the opening html, the entire head section, all ok then 2 opening body tags (you can only have one) and has some navigation and then an image you basically use as main content.

    Then the rest of the index.php file gets loaded. 2 opening body tags (which makes 4) again, the nav, again that same main content image. Ends with closing the entire html document off and then calling the wp_footer().

    You see the problem? It’s a flow and you’re loading a lot of things twice.

    It’s ok to have the nav inside the header file. So, let’s keep that there.
    So in your index.php, delete everything starting with the first opening body tag (line 10) and ending with the closing div tag of the nav div (line 22). Also leave out <?php wp_footer(); ?> for now. We’ll solve that later.

    In your header-home.php delete the home-content div and the following closing div of the wrapper. (lines 35 and 36)

    Not sure why you can’t edit these files inside WP.

    Thread Starter Maracas1970

    (@maracas1970)

    The problem really does seem to be that it cannot reference the header-home.php file. For some god forsaken reason it just aint doing it..

    Peter_L

    (@peter_l)

    can you mail me the theme folder to [email protected] ?

    Thread Starter Maracas1970

    (@maracas1970)

    Sure..

    Thread Starter Maracas1970

    (@maracas1970)

    I sent, thankyou..

Viewing 15 replies - 16 through 30 (of 30 total)
  • The topic ‘Can not remove header and footer from homepage’ is closed to new replies.