Ask your WordPress questions! Pay money and get answers fast! Comodo Trusted Site Seal
Official PayPal Seal

Hiding Masthead from Template I created WordPress

  • SOLVED

Hello its been a while, nice to be back.

Ok, my site is at [[LINK href="http://ledesmaphotography.com/projects-copy/"]]http://ledesmaphotography.com/projects-copy/[[/LINK]]

and the url is showing a page template I created of the main default full width template. What I did was just remove the call for the sidebar and update the css call on the page to the one you see and I like it just fine.

My only problem is that I can't figure out how to remove the masthead from that <strong>template only</strong>, the new one I created.



<code><?php

/**
* Template Name: Full Width Modified Page
* Description: A full width page without the sidebars below the content.

*/

if (__FILE__ == $_SERVER['SCRIPT_FILENAME']) { die(); }
if (CFCT_DEBUG) { cfct_banner(__FILE__); }

get_header();

?>

</div>
<div class="container clearfix">

<?php
cfct_loop();

?>

</div><!--.page-full-->


<?php get_footer(); ?> <code>

Answers (3)

2013-12-21

Bob answers:

You can use <?php is_page_template($template); ?> wordpress tag to show or hide something from header.

Example:
if ( is_page_template('about.php') ) {
// Returns true when 'about.php' is being used.
} else {
// Returns false when 'about.php' is not being used.
}

you can use it in header.php



Jorge Ledesma comments:

this seems like a the way to go, instead of creating a new header php and calling it something else.


Bob comments:

if you do not want some code to be displayed in template.php page which has get_header() and it is showing header.php content then try this example

if ( ! is_page_template('template.php') ) {

Your Masthead code

}


Jorge Ledesma comments:

Something like this:

<code> if ( is_page_template('page-full-modified.php') ) {
// Returns true when 'page-full-modified.php' is being used.
} else {
// Returns false when 'page-full-modified.php' is not being used.

<code>

But how do you hide the masthead.


Jorge Ledesma comments:

I understand what you're saying but I can't find the part which calls for the Masthead in the header.php . I link above to the files of the theme for reference.


Bob comments:

if you want to show Masthead only on home page then you can also try is_home() and is_front_page() template tags in header.php.


Bob comments:

ok going to download it.


Jorge Ledesma comments:

No, all I want is for this template not to display the Masthead, the rest of the theme stays as is - just this template.


Jorge Ledesma comments:

here's the link to the php file I'm talking about https://www.dropbox.com/s/m9651oj3n7e8dab/page-full-modified.php and it goes in the root


Jorge Ledesma comments:

That template gives me this template option in the admin of any page https://www.dropbox.com/s/ibn8lq3bnojjbn4/Screenshot%202013-12-21%2014.03.17.png


Bob comments:

go to headers/featured-image.php and change code with below
if ( !is_page_template('page-full-modified.php') ) {
<section id="masthead">
<div class="container clearfix">
<img src="<?php header_image(); ?>" width="<?php echo HEADER_IMAGE_WIDTH; ?>" height="<?php echo HEADER_IMAGE_HEIGHT; ?>" alt="" />
</div><!-- .container -->
</section><!-- #masthead -->
}


go to headers/featured-posts.php and change code with below
if ( !is_page_template('page-full-modified.php') ) {

<section id="masthead">
<div class="container clearfix">
<div id="featured-posts" class="clearfix cf-clearfix">
<?php

echo $content;

?>
</div>
</div><!-- .container -->
</section><!-- #masthead -->


}


Jorge Ledesma comments:

let me try it now.


Bob comments:

Modified version. Forgot opening and closing php tag.

go to headers/featured-image.php and change code with below
<?php
if ( !is_page_template('page-full-modified.php') ) {
?>
<section id="masthead">
<div class="container clearfix">
<img src="<?php header_image(); ?>" width="<?php echo HEADER_IMAGE_WIDTH; ?>" height="<?php echo HEADER_IMAGE_HEIGHT; ?>" alt="" />
</div><!-- .container -->
</section><!-- #masthead -->
<?php } ?>


go to headers/featured-posts.php and change code with below
<?php
if ( !is_page_template('page-full-modified.php') ) {
?>
<section id="masthead">
<div class="container clearfix">
<div id="featured-posts" class="clearfix cf-clearfix">
<?php

echo $content;

?>
</div>
</div><!-- .container -->
</section><!-- #masthead -->
<?php } ?>


Jorge Ledesma comments:

it gave an error http://ledesmaphotography.com/projects/


Jorge Ledesma comments:

You got it! Thanks, you won!


Bob comments:

can you post error message here.


Bob comments:

Thanks Jorge Ledesma

2013-12-21

Hariprasad Vijayan answers:

Hello,

Can you show a screenshot of the part you want to remove?


Jorge Ledesma comments:

Here's the masthead

https://www.dropbox.com/s/8qoh8a4aodwk3l9/Screenshot%202013-12-21%2013.41.25.png


Hariprasad Vijayan comments:

Can you tell me the php file name that you are newly created?


Jorge Ledesma comments:

page-full-modified.php


Jorge Ledesma comments:

you can grab it from the dropbox link for the theme files.


Hariprasad Vijayan comments:

I can't see a file named page-full-modified.php in that dropbox link.


Jorge Ledesma comments:

Sorry its the original files I sent you, here's the link to the php file I'm talking about https://www.dropbox.com/s/m9651oj3n7e8dab/page-full-modified.php and it goes in the root

2013-12-21

Remy answers:

You can create an alternate header template by copying the original and removing what you want. Then you call it by it´s name in get_header (ie. get_header( 'full' ) )


Jorge Ledesma comments:

Yup, I know but I can't figure out where. Here's a link to the files:

https://www.dropbox.com/s/6voxcuy0jtm8282/favepersonal.zip


Jorge Ledesma comments:

I created in the root of the folder this file:

page-full-modified.php which is the template that is being called for

<code>
<?php



/**

* Template Name: Full Width Modified Page

* Description: A full width page without the sidebars below the content.



*/



if (__FILE__ == $_SERVER['SCRIPT_FILENAME']) { die(); }

if (CFCT_DEBUG) { cfct_banner(__FILE__); }



get_header();



?>



</div>

<div class="container clearfix">



<?php

cfct_loop();



?>



</div><!--.page-full-->





<?php get_footer(); ?>

<code>


Jorge Ledesma comments:

Here's a screenshot of the theme setting as well:

https://www.dropbox.com/s/c1bujx92sdrqe6d/Screenshot%202013-12-21%2013.47.40.png