[英]Page Template does not display in drop down menu
我是PHP新手,我使用Genesis框架制作了第一個自定義頁面模板。
我已經為主要父代Genesis創建了一個主題子代,它是活躍的且可識別為子代,主題儀表板上沒有錯誤。
問題很簡單,當我將模板放置在父目錄中時,沒問題,創建新頁面時,它會顯示在頁面模板選擇的下拉菜單中,但是,當我將其放置在子主題的目錄中時,它現在顯示。
我試圖將index.php復制到子目錄,但沒有成功,它僅顯示在父目錄中。
我到處都看過,有一個問題,我認為這是通過wordpress方法找到的,該問題僅在父母的目錄上查找主題模板,而沒有孩子。
任何建議將不勝感激。
有模板的代碼:
<?php
/*
Template Name: About Template
*/
?>
<?php get_header(); ?>
<div id="primary" class="content-area">
<main id="main" class="site-main" role="main">
<?php
// Start the loop.
while ( have_posts() ) : the_post(); ?>
<article id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
<header class="entry-header">
<?php the_title( '<h1 class="entry-title">', '</h1>' ); ?>
</header><!-- .entry-header -->
<div class="entry-content">
<?php if ( have_rows('about') ):
while ( have_rows('about') ): the_row(); ?>
<h2><?php the_sub_field('content_area'); ?></h2>
</div><!-- .entry-content -->
</article><!-- #post-## -->
<?php endwhile; // End the loop. ?>
</main><!-- .site-main -->
</div><!-- .content-area -->
<?php get_footer(); ?>
<?php
/**
* Template Name: Template Nmae
*
* @package WordPress
* @subpackage Twenty_Fourteen
* @since Twenty Fourteen 1.0
*/
<div id="primary" class="content-area">
<main id="main" class="site-main" role="main">
<?php
// Start the loop.
while ( have_posts() ) : the_post(); ?>
<article id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
<header class="entry-header">
<?php the_title( '<h1 class="entry-title">', '</h1>' ); ?>
</header><!-- .entry-header -->
<div class="entry-content">
<?php if ( have_rows('about') ):
while ( have_rows('about') ): the_row(); ?>
<h2><?php the_sub_field('content_area'); ?></h2>
</div><!-- .entry-content -->
</article><!-- #post-## -->
<?php endwhile; // End the loop. ?>
</main><!-- .site-main -->
</div><!-- .content-area -->
<?php get_footer(); ?>
提供所需的模板名稱,然后從頁面的管理區域中選擇比前端顯示的模板名稱。
使用此代碼將起作用
<?php
/*
Template Name:New template name
*/
get_header();?>
<div id="primary" class="content-area">
<main id="main" class="site-main" role="main">
<?php
// Start the loop.
while ( have_posts() ) : the_post(); ?>
<article id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
<header class="entry-header">
<?php the_title( '<h1 class="entry-title">', '</h1>' ); ?>
</header><!-- .entry-header -->
<div class="entry-content">
<?php if ( have_rows('about') ):
while ( have_rows('about') ): the_row(); ?>
<h2><?php the_sub_field('content_area'); ?></h2>
</div><!-- .entry-content -->
</article><!-- #post-## -->
<?php endwhile; // End the loop. ?>
</main><!-- .site-main -->
</div><!-- .content-area -->
<?php get_footer();?>
使用它在我的孩子創世紀主題中起作用
<?php
/*
Template Name: Template Nmae
*/
?>
<div id="primary" class="content-area">
<main id="main" class="site-main" role="main">
<?php
// Start the loop.
while ( have_posts() ) : the_post(); ?>
<article id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
<header class="entry-header">
<?php the_title( '<h1 class="entry-title">', '</h1>' ); ?>
</header><!-- .entry-header -->
<div class="entry-content">
<?php if ( have_rows('about') ):
while ( have_rows('about') ): the_row(); ?>
<h2><?php the_sub_field('content_area'); ?></h2>
</div><!-- .entry-content -->
</article><!-- #post-## -->
<?php endwhile; // End the loop. ?>
</main><!-- .site-main -->
</div><!-- .content-area -->
<?php get_footer(); ?>
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.