2016-04-12 71 views
0

我是PHP新手,使用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(); ?> 

回答

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

給你想要的模板名稱,並從頁面的管理區域的模板名稱比它顯示在前端。

+0

我不希望使用父頁面了新的一頁,我米尋找使用頁面模板的一個新的頁面,除非我把模板放在父主題,它不是通過兒童主題工作... – Ozzy

+0

你可以分享代碼? –

+0

添加了模板代碼 – Ozzy

0

使用此代碼,它會工作

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

我已經把模板名稱的註釋放入了代碼中,但是我重新編輯了它。 – Ozzy

0

使用此它工作在我的孩子成因主題

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

這不適合我... – Ozzy