This relates to this previously asked question.
I followed exactly the advice given but it doesn't seem to work?
The advice was: "Duplicate the header.php to header-{custom-name}.php, let's say (header-nonavfooter.php) then in the template file replace get_header() with get_header('nonavfooter'). In the new header file (header-nonavfooter.php) remove the code related to navigation."
At the top of the template I'd like to have no navigation or footer is this:
<?php
/*
* Template Name: No Navigation/ No Header
*/
if (!defined('ABSPATH'))
exit; // Exit if accessed directly
get_header('headerremoved');
?>
I created a file called headerremoved.php (with the removed navigation) but it still loads the navigation which suggests this template is loading the original header...
Very confused why it isn't working - is there something I should be looking for to problem-solve here?
+++
My headerremoved.php (named like that) is like this:
<?php
if (!defined('ABSPATH'))
exit; // Exit if accessed directly
/**
* The Header for our theme
*
* Displays all of the <head> section and everything up till <div
id="main">
*
* @package WordPress
* @subpackage
* @since 2015
*/
?><!DOCTYPE html>
<!--[if IE 7]>
<html class="ie ie7" <?php language_attributes(); ?>>
<![endif]-->
<!--[if IE 8]>
<html class="ie ie8" <?php language_attributes(); ?>>
<![endif]-->
<!--[if !(IE 7) & !(IE 8)]><!-->
<html <?php language_attributes(); ?>>
<!--<![endif]-->
<head>
<meta charset="<?php bloginfo('charset'); ?>">
<meta name="viewport" content="width=device-width, initial-
scale=1.0" />
<link rel="profile" href="http://gmpg.org/xfn/11">
<link rel="pingback" href="<?php bloginfo('pingback_url'); ?>">
<!-- HTML5 Shim and Respond.js IE8 support of HTML5 elements and media queries -->
<!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
<!--[if lt IE 9]>
<script src="https://oss.maxcdn.com/libs/html5shiv/3.7.0/html5shiv.js"></script>
<script src="https://oss.maxcdn.com/libs/respond.js/1.3.0/respond.min.js"></script>
<![endif]-->
<!--[if lt IE 9]>
<script src="<?php echo esc_url(get_template_directory_uri()); ?>/js/html5.js"></script>
<![endif]-->
<!-- GTM IC 20170805 -->
<script>(function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({'gtm.start':
new Date().getTime(),event:'gtm.js'});var f=d.getElementsByTagName(s)[0],
j=d.createElement(s),dl=l!='dataLayer'?'&l='+l:'';j.async=true;j.src=
'https://www.googletagmanager.com/gtm.js?id='+i+dl;f.parentNode.insertBefore(j,f);
})(window,document,'script','dataLayer','XXX');</script>
<!-- <link href="https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css" rel="stylesheet"> -->
<link href="https://fonts.googleapis.com/css?family=Ubuntu" rel="stylesheet">
<?php wp_head(); ?>
</head>
<body <?php body_class(); ?>>
<!-- GTM IC 20170805 -->
<noscript><iframe src="https://www.googletagmanager.com/ns.html?id=XXX"
height="0" width="0" style="display:none;visibility:hidden"></iframe></noscript>
<!-- navigation removed -->
The top of my template file looks like this:
<?php
/*
* Template Name: No Header
*/
if (!defined('ABSPATH'))
exit; // Exit if accessed directly
get_header('header-headerremoved');
?>
get_header()
line completely. What happens?headerremoved.php
file? By the way, the file name should beheader-headerremoved.php
to work.get_header('header-headerremoved');
, WordPress will automatically add aheader-
prefix, and look for the file. For example, it will look forheader-header-headerremoved.php
in your case. So, rename your file toheader-headerremoved.php
, and useget_header('headerremoved');