WordPress.org

Support

Support » How-To and Troubleshooting » Can not remove header and footer from homepage

Can not remove header and footer from homepage

  • Maracas1970
    Member

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

    http://pastebin.com/f3HnBYyw

    My header

    http://pastebin.com/BTCnpsJ4

    My footer

    http://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 - 1 through 15 (of 30 total)
  • Can you please post your code to pastebin.com? It was mucking up the forums.

    Maracas1970
    Member

    @maracas1970

    Apologies, hopefully that`s better.

    You need both header and footer on each page. They should inlcude things like your opening and closing html and body tags.

    What you should do is put the content inside the header and footer files you don’t want to show up inside those if conditionals.

    Maracas1970
    Member

    @maracas1970

    Thank you Peter_L

    I realise that i need the opening and closing page tags, in order to have a fully functional document.

    The thing is i just don’t want the header and footer on the homepage. I need to find a way to remove these from that landing page, do i wrap the header and footer.php code in a conditional to say such as, if this is the homepage leave out header and footer?

    I am truly stumped, and have a pulsating brain headache ;>

    The home page is index.php
    Other pages use the page.php template file.

    So just leave out get_header and get_footer on the index.php.

    Watch it though, this wil cause other problems. You need the wp_head() and wp_footer() and these are usually in the header.php and footer.php.

    Maracas1970
    Member

    @maracas1970

    OK. Removing these got me:

    Parse error: syntax error, unexpected ‘<‘ in /var/www/html/wp-content/themes/BPR/index.php on line 13

    Do i need to change anything in header and footer.php before i remove these tags please?

    Thankyou

    Maracas1970
    Member

    @maracas1970

    Did you mean i needed the need the wp_head() and wp_footer() in the index.php or in the header and footer files, as they are on the header and footer files, just not in the index.php now i have removed them.

    Warm regards

    Kark

    I’m saying you need a header and footer. WordPress needs them.

    Here’s a solution:
    Make a new header.php and footer.php

    But call them
    header-home.php and footer-home.php

    Put in these files what you want for the home page. In other words, detle what you don’t want from this one http://pastebin.com/BTCnpsJ4, put leave all the rest.

    Inside the index.php, call
    get_header(‘home’);
    this will call the header-home.php
    where as get_header();
    calls the header.php template

    That should solve your problem.

    The parse error from a bove is a syntax error. You pade a mistake in the php language.
    But start above, do the stuff I wrote here. That should work, I use it all the time.

    Maracas1970
    Member

    @maracas1970

    ok so when i do that all the styling goes, and i`m left with get_header(‘home’); at the top left of the page along with all the unstyled links..

    Do i have to copy over all the index.php code into the header-home.php and footer-home.php files? And leave nothing else.
    And delete reference to get footer and get header on the index.php.
    And just add get_header(‘home’); at the top of the index.php?

    Im sorry, im really confused. Maybe something is lost in translation here, or maybe i`m just tired..

    Maracas1970
    Member

    @maracas1970

    Progress! Got rid of the header, And got rid of the text.

    Hopefully can repeat for footer afterwards, and be on my way…

    Maracas1970
    Member

    @maracas1970

    Hi there.

    Well i thought it was working, but when i checked the header.php file i noticed i`d taken the code out of there aswell as the header-home.php file, when i added it back to the header the same thing happened, unwanted navigation intended for the rest of my pages appeared.

    I did everything you said, the header-home file is in the theme folder as is the footer-home.php which incidentally seems to work.

    Here is my updated index.php

    Maracas1970
    Member

    @maracas1970

    I guess while im at it, heres a link to the website..

    http://www.gotodesigns.co.uk

    Need to get rid of the blue icons and text at the top.
    It just doesnt seem to be calling the header-home.php for some reason.

    You’re not getting the thing you’re doing.
    This isn’t a conditional. It’s a call for a specific template file. If you call both files, both files will show.
    Read this http://codex.wordpress.org/Function_Reference/get_header

    You call both:

    get_header(‘home’);
    get_header();

    so both will show

    +

    all the code between rule 15-25, you put inside the header-home.php
    on rule 26 you call wp_head() (inside the header-home.php file)

    header-home.php isn’t an empty file you call, it should contain all the header info for the page you call it for. In this case, all header info of your home page.

    Maracas1970
    Member

    @maracas1970

    Do i need all this in my index page:
    <title><?php wp_title(‘«’, true, ‘right’); ?> <?php bloginfo(‘name’); ?></title>
    <link rel=”stylesheet” href=”<?php bloginfo(‘stylesheet_url’); ?>” type=”text/css” media=”screen” />
    <link rel=”pingback” href=”<?php bloginfo(‘pingback_url’); ?>” />
    <?php wp_head(); ?>

    because when i added that before the end head tags, it seemed to work even when i exclude the get_header(‘home’); its really bizarre..

    When it`s excluded just with the get_header(‘home’); included, all the styling disappears. Until i put it back in.

    Maracas1970
    Member

    @maracas1970

    Thanks for all the time/help you put in so far by the way.

    As you can see, i am only just beginning with PHP & WordPress.

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