Making WordPress.org


Ignore:
Timestamp:
03/30/2018 10:53:39 PM (9 years ago)
Author:
iandunn
Message:

WP15: Use child theme pages templates for the static front page.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • sites/trunk/wp15.wordpress.net/public_html/content/themes/twentyseventeen-wp15/functions.php

    r6985 r6989  
    55defined( 'WPINC' ) || die();
    66
     7add_filter( 'template_include',   __NAMESPACE__ . '\get_front_page_template' );
    78add_action( 'wp_enqueue_scripts', __NAMESPACE__ . '\enqueue_scripts' );
    89add_filter( 'get_custom_logo',    __NAMESPACE__ . '\set_custom_logo' );
    910add_filter( 'body_class',         __NAMESPACE__ . '\add_body_classes' );
     11
     12
     13/**
     14 * Bypass TwentySeventeen's front-page template.
     15 *
     16 * When a static front page is configured, its corresponding template should be used to render the page, not
     17 * TwentySeventeen's generic front-page template.
     18 *
     19 * @param string $template
     20 *
     21 * @return string
     22 */
     23function get_front_page_template( $template ) {
     24        if ( false !== strpos( $template, 'twentyseventeen/front-page.php' ) ) {
     25                $template = get_page_template();
     26        }
     27
     28        return $template;
     29}
    1030
    1131/**
Note: See TracChangeset for help on using the changeset viewer.