使用页面模板中的\\u内容时,不会显示任何内容。
循环调用索引中的页面模板:
index.php
<?php
/**
* Main template file
*
* This is the most generic template file in a WordPress theme
* and one of the two required files for a theme (the other being style.css).
* It is used to display a page when nothing more specific matches a query.
* E.g., it puts together the home page when no home.php file exists.
* Learn more: http://codex.wordpress.org/Template_Hierarchy
*
* @package WordPress
* @subpackage Twenty_Eleven
*/
get_header();
$pages = get_pages();
foreach ($pages as $page_data) {
$title = $page_data->post_title;
$template = get_post_meta( $page_data->ID, \'_wp_page_template\', true );
switch($template) {
case \'template-portfolio.php\':
get_template_part( \'includes/portfolio\' );
break;
case \'template-landing.php\':
echo get_template_part( \'includes/landing\' );
break;
}
}
get_footer();
landing.php
:<div id="opening" style="width:100%; height:100vh; background: white; background-size:cover; margin: 0 0 -86px 0; ">
<div id="text_opening">
<!--<?php $paged = (get_query_var(\'paged\')) ? get_query_var(\'paged\') : 1; ?>
Stai visitando la pagina <?php echo $paged; ?>-->
<?php while ( have_posts() ) : the_post(); ?> <!--Because the_content() works only inside a WP Loop -->
<div class="entry-content-page">
<?php the_content(); ?> <!-- Page Content -->
</div><!-- .entry-content-page -->
<?php
endwhile; //resetting the page loop
wp_reset_query(); //resetting the page query
?>
</div>
</div>
template-landing.php
:<?php
/*
Template Name: Landing
*/
get_header();
echo get_template_part( \'includes/landing\' );
get_footer();
但它不起作用,我只能看到这个类的div;条目内容页;但是它是空的,我只需要显示内容<奇怪的是,如果我点击;“查看页面”;在管理面板中,预览显示了内容,但我的网站中没有<有什么想法吗<谢谢!