0

I created a new WordPress Template named "Footer page". When a new page is created in WordPress and the user selects the template "Footer page" the new page should not appear in the navigation bar.

I did some research and found something called "Exclude Pages from List" that says "Use the exclude parameter to hide certain Pages from the list to be generated by wp_list_pages." but have no idea where I should put it my template file? Or if this is the best way to exclude a template page from the navigation bar?

My code for footer-page.php is as follows:

<?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(); ?>
4

1 回答 1

0

你可以试试这样:

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

读这个

于 2012-12-21T04:57:43.607 回答