AnsPress_Theme::anspress_basepage_template( string $template )
Description #
Check if anspress.php file exists in theme. If exists then load this template for AnsPress.
Parameters #
- $templatestring (Required) Template.
Changelog #
Source #
File: includes/class-theme.php
public static function anspress_basepage_template( $template ) {
if ( is_anspress() ) {
$templates = array( 'anspress.php', 'page.php', 'singular.php', 'index.php' );
if ( function_exists( 'wp_is_block_theme' ) && wp_is_block_theme() ) {
$templates = array();
}
if ( is_page() ) {
$_post = get_queried_object();
array_unshift( $templates, 'page-' . $_post->ID . '.php' );
array_unshift( $templates, 'page-' . $_post->post_name . '.php' );
$page_template = get_post_meta( $_post->ID, '_wp_page_template', true );
if ( ! empty( $page_template ) && 'default' !== $page_template ) {
array_unshift( $templates, $page_template );
}
} elseif ( is_single() ) {
$_post = get_queried_object();
array_unshift( $templates, 'single-' . $_post->ID . '.php' );
array_unshift( $templates, 'single-' . $_post->post_name . '.php' );
array_unshift( $templates, 'single-' . $_post->post_type . '.php' );
} elseif ( is_tax() ) {
$_term = get_queried_object();
$term_type = str_replace( 'question_', '', $_term->taxonomy );
array_unshift( $templates, 'anspress-' . $term_type . '.php' );
}
$new_template = locate_template( $templates );
if ( '' !== $new_template ) {
return $new_template;
}
}
return $template;
}
Expand full source code Collapse full source code View on GitHub: includes/class-theme.php:261
Add your comment