• Resolved Smithy963

    (@smithy963)


    Hi guys,

    A semi-newb question I guess, I’m on a time limit.

    I’m trying to remove the header and navigation from the single.php page.

    ~I tried commenting out the header at the top of single.php
    <!--<?php get_header(); ?>-->

    What has this done? (nothing that I can see)

    ~So I start editing header.php:

    <?php if( !is_page('<strong>single</strong>') ) { ?>
    
    <div> This is all my header stuff, logo, navigation etc.</div>
    <?php } ?>

    By using the is_page() function I don’t know how to identify which page is which.

    What ID is single.php (where can i find it)?
    Can single.php resolve to a range of ID values dependable upon the data it is reflecting?

    Thanks in advance,
    Smithy.

Viewing 3 replies - 1 through 3 (of 3 total)
  • You shouldn’t comment out the get_header, cause there is a lot more than “graphical stuff” in the header template file, i.e. all the html code before the <body>… You’ll need it even if you don’t want nothing to be displayed.

    Your mistake in your code is that ‘Single’ is not the title of a page… It’s the name of the template page.

    Try something like this :

    <?php if(is_single()) { ?>
    My stuff for the single post
    <?php } ?>
    
    <?php else { ?>
    My stuff for anything else
    <?php } ?>

    S.

    Thread Starter Smithy963

    (@smithy963)

    Spot on my friend, thank you very much.

    I put my get_header() back into single.php, and added in this line of code to remove the header/navigation from the single page only:

    header.php:

    <?php if( !is_single() ) { ?>
    	<div id="header">
    	</div><!-- header -->
    
    	<div id="navigation">
    	</div><!-- navigation -->
    <?php } ?>

    This means the header and navigation will only show when the page is not single.php

    I have other pages on my site (other than the homepage) which require the header and navigation menu and all my single posts are launched into a new child window which does not require the header/navigation.

    Thanks again for the speedy reply,
    Smithy.

    Thread Starter Smithy963

    (@smithy963)

    Is there such a thing as ‘high five’ or ‘mark as correct answer’ on this site?

    EDIT: This topic is resolved (drop down list on the right, midway up the page).

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Remove Header from Single.php’ is closed to new replies.