[英]Scratch wordpress theme is not showing page content for page.php
[英]Wordpress: cannot see content in page.php, only sidebar
我已经创建了自己的主题,并将其他标准Wordpress主题的代码复制并粘贴到了page.php中,但是它不会显示内容,仅在侧边栏显示(如果代码需要)。
我从二十七岁复制的page.php代码示例:
<?php
/**
* The 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
*/
get_header(); ?>
<div class="wrap">
<div id="primary" class="content-area">
<main id="main" class="site-main" role="main">
<?php
while ( have_posts() ) : the_post();
get_template_part( 'template-parts/page/content', 'page' );
// 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;
endwhile; // End of the loop.
?>
</main><!-- #main -->
</div><!-- #primary -->
</div><!-- .wrap -->
<?php get_footer();
我已经创建了许多不同的自定义页面模板,它们都可以很好地显示内容。
我用默认模板(page.php)创建了一个非常标准的新页面,并在管理面板中添加了文本(因此不是直接添加到模板中),但是查看时不会显示此文本或任何简码或其他输入完成的页面。
无法找出丢失的内容。 任何帮助将不胜感激,谢谢。
我假设您在template-parts / page中没有文件content-page.php? 如果不是,则从Twentyseventeen主题复制并粘贴整个template-parts文件夹,或替换行'get_template_part('template-parts / page / content','page');' 使用“ the_content();”
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.