admin管理员组文章数量:1302273
I've created a custom page template with a hero and a subnavigation section that fetches some data from custom fields and shows a menu. Here's the code:
<?php
/**
* Template Name: Hero Page Template
*
* Template for displaying a page with Hero and sub navigation component.
*
* @package understrap
*/
// Exit if accessed directly.
defined( 'ABSPATH' ) || exit;
get_header();
$container = get_theme_mod( 'understrap_container_type' );
?>
<div class="wrapper" id="hero-template-wrapper">
<div class="<?php echo esc_attr( $container ); ?>" id="content">
<div class="row">
<div class="col-md-12 content-area" id="primary">
<main class="site-main" id="main" role="main">
<?php
$bg = get_field('hero_background');
if(strlen($bg) > 0) {
echo "<section class='hero-section' style='background-image: url($bg);'>";
} else {
echo "<section class='hero-section'>";
}
?>
<div class="container-box">
<span><?php the_field('hero_label') ?></span>
<h1><?php the_field('hero_title') ?></h1>
</div>
</section>
<div class="subnav-container">
<?php global $post;
$menu_name = get_post_meta($post->ID, "subnav_choice", true);
$options = array(
'menu' => $menu_name,
'menu_class' => 'subnav',
'echo' => false,
);
echo wp_nav_menu($options); ?>
</div>
<?php while ( have_posts() ) : the_post(); ?>
<?php get_template_part( 'loop-templates/content', 'page' ); ?>
<?php
// If comments are open or we have at least one comment, load up the comment template.
if ( comments_open() || get_comments_number() ) :
comments_template();
endif;
?>
<?php endwhile; // end of the loop. ?>
</main>
</div>
</div>
</div>
</div>
<?php get_footer(); ?>
This is working fine on local WP installation. But in actual Wordpress, whenever I update the template of a page to this and reload the page, it switches back to "Empty page template". I guess this means WP is not saving it, Please help!
本文标签: themesWordpress keeps switching back to empty template
版权声明:本文标题:themes - Wordpress keeps switching back to empty template 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741679031a2392055.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论