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


I’ve built a custom page template in my twentyseventeen child theme that I know is working fine when I go directly to that page but when I set home page of my site to be a static and pointing to that page nothing displays. It will display any of text I have in the body but it does not seem to run any of the code in the template.

The static home page is here: https://wanderreader.com/

The page running on its own is here: https://wanderreader.com/book-list/#

I based my template on the TwentySeventeen page.php and, like I said, I know the code is working fine when I run the page on its own (i.e. not as a static home page) so I’m really scratching my head as to why it doesn’t run any of my code when I set it to the home page.

* 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


//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 id="SelectedCategory">
      <a href="#" onclick="categorySubmit('<?php echo $ajax_nonce?>', 0)">Home</a>
      <div id="FilterCategories">
            $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 id="BookList">

      <div id="BookCovers">

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

  <?php get_footer();


You may want to take a look at this document: 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

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

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

I think in your case you just need to edit or create front-page.php instead of page.php.

Answered By – Jared Chu

This Answer collected from stackoverflow, is licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0

Leave a Reply

(*) Required, Your email will not be published