这与之前提出的问题有关question.
我完全按照给出的建议做了,但似乎不起作用?
建议是:“将header.php复制到header-{custom name}.php,比方说(header nonavfooter.php),然后在模板文件中将get\\u header()替换为get\\u header(\'nonavfooter\')。在新的头文件(header nonavfooter.php)中删除与导航相关的代码。”
在模板顶部,我希望没有导航或页脚,如下所示:
<?php
/*
* Template Name: No Navigation/ No Header
*/
if (!defined(\'ABSPATH\'))
exit; // Exit if accessed directly
get_header(\'headerremoved\');
?>
我创建了一个名为
headerremoved.php (使用删除的导航)但仍会加载导航,这表明此模板正在加载原始标题。。。
非常困惑为什么它不起作用-我是否应该在这里寻找解决问题的方法?
+++
我的头动了。php(命名如下)如下:
<?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 -->
我的模板文件的顶部如下所示:
<?php
/*
* Template Name: No Header
*/
if (!defined(\'ABSPATH\'))
exit; // Exit if accessed directly
get_header(\'header-headerremoved\');
?>