【问题标题】:WordPress Templates - How do I exclude a template from the navigation bar?WordPress 模板 - 如何从导航栏中排除模板?
【发布时间】:2012-12-21 02:13:28
【问题描述】:

我创建了一个名为“页脚”的新 WordPress 模板。当在 WordPress 中创建新页面并且用户选择模板“页脚页面”时,新页面不应出现在导航栏中。

我做了一些研究,发现了一个名为“从列表中排除页面”的内容,上面写着“使用排除参数从 wp_list_pages 生成的列表中隐藏某些页面”。但不知道我应该把它放在哪里我的模板文件?或者如果这是从导航栏中排除模板页面的最佳方式?

我的footer-page.php代码如下:

<?php
/**
 * Template Name: Footer page
 *
 * A custom page template that does not appear in the navigation bar.
 *
 * The "Template Name:" bit above allows this to be selectable
 * from a dropdown menu on the edit page screen.
 *
 * @package WordPress
 * @subpackage Twenty_Ten
 * @since Twenty Ten 1.0
 */

get_header(); ?>

        <div id="container" class="one-column">
            <div id="content" role="main">

            <?php
            /* Run the loop to output the page.
             * If you want to overload this in a child theme then include a file
             * called loop-page.php and that will be used instead.
             */
             get_template_part( 'loop', 'page' );
            ?>

            </div><!-- #content -->
        </div><!-- #container -->

<?php get_footer(); ?>

【问题讨论】:

  • 您没有在仪表板中的外观->菜单下设置菜单是否有特殊原因?

标签: wordpress wordpress-theming


【解决方案1】:

你可以这样尝试:

if (is_page('1') || is_page('5')) { // 包括模板“sidebar.php”。 获取模板部分(“循环”,“页面”); }

read this

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2011-11-19
    • 2015-03-05
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-04-20
    • 1970-01-01
    相关资源
    最近更新 更多