WordPress Twenty 17 静态主页不执行我的自定义模板

WordPress Twenty Seventeen static home page doesn't execute my custom template

我在我的 twentyseventeen 子主题中构建了一个自定义页面模板,我知道当我直接转到该页面时它工作正常,但是当我将我的站点的主页设置为静态并指向该页面时什么也没有显示。它会显示我在正文中的任何文本,但似乎 运行 模板中的任何代码都不会显示。

静态主页在这里:https://wanderreader.com/

页面 运行ning 本身位于此处:https://wanderreader.com/book-list/#

我的模板基于 TwentySeventeen page.php,就像我说的,当我 运行 自己的页面(即不是静态主页)时,我知道代码工作正常) 所以我真的很想知道为什么当我将它设置到主页时它没有 运行 我的任何代码。

如有任何想法,我们将不胜感激。

提前致谢, 本

编辑为 post 页面来源:

<?php
/**
* Template Name: TravelBooksHome
*
* Derived from the 'page' template for displaying all pages
*
* This is the template that displays all pages by default.
* Please note that this is the WordPress construct of pages
* and that other 'pages' on your WordPress site may use a
* different template.
*
* @link https://codex.wordpress.org/Template_Hierarchy
*
* @package WordPress
* @subpackage Twenty_Seventeen
* @since 1.0
* @version 1.0
*/

get_header();

//Set the Nonce to avoid any shenanigans with the ajax calls
$ajax_nonce = wp_create_nonce( "<removed for posting>" );

?>

  <div class="wrap">
    <div id="primary" class="content-area">
      <main id="main" class="site-main" role="main">


    <div id="MessageArea">
    </div>

    <div id="SelectedCategory">
      <a href="#" onclick="categorySubmit('<?php echo $ajax_nonce?>', 0)">Home</a>
      <br>
    </div>
    <hr>
      <div id="FilterCategories">
        <?php
            $categories = get_categories( array(
            'orderby' => 'name',
            'show_count' => true,
            'echo' => false,
            'title_li' => '',
            'depth' => '1',
            'use_desc_for_title'    => false,
            'parent'  => 0
            ) );

        foreach ( $categories as $category ) {
            printf( '<a href="#" onclick="%1$s">%2$s</a><br />',
            "categorySubmit('".$ajax_nonce."', ". $category->term_id .")",
            esc_html( $category->name )
            );
        }
        ?>
      </div>

      <hr>
      <div id="BookList">
      </div>

      <div id="BookCovers">
      </div>


      </main>
      <!-- #main -->
    </div>
    <!-- #primary -->
  </div>
  <!-- .wrap -->

  <?php get_footer();

您可能想看看这个文档:https://codex.wordpress.org/Creating_a_Static_Front_Page

On the site front page, WordPress will always use the front-page.php template file, if it exists. If front-page.php does not exist, WordPress will determine which template file to use, depending on the user configuration of 'Settings > Reading ->Front page displays', as follows:

A static page: WordPress uses the Static Page template hierarchy: Custom Page Template, page-{id}.php, page-{slug}.php, page.php, index.php

Your latest posts: WordPress uses the Blog Posts Index template hierarchy: home.php, index.php

我认为在您的情况下,您只需要编辑或创建 front-page.php 而不是 page.php