[英]wordpress single post content not showing
Wordpress single blog post's content is not showing. Wordpress单个博客文章的内容未显示。 I have tried this and this but I didn't understand why it's not working.
我曾尝试这个和这个 ,但我不明白为什么它不工作。 It looks good for me, is there any other files to check for this problem ?
对我来说看起来不错,是否还有其他文件可检查此问题?
Here is my single.php 这是我的single.php
get_header(); ?>
<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/content', get_post_format() );
the_post_navigation();
// 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 -->
<?php
get_sidebar();
get_footer();
If you want to show the post content, you need to use <?php the_content(); ?>
如果要显示帖子内容,则需要使用
<?php the_content(); ?>
<?php the_content(); ?>
or similar. <?php the_content(); ?>
或类似。
Use this code 使用此代码
get_header(); ?>
<div id="primary" class="content-area">
<div id="content" class="site-content" role="main">
<?php /* The loop */ ?>
<?php while ( have_posts() ) : the_post(); ?>
<?php get_template_part( 'content', get_post_format() ); ?>
<?php twentythirteen_post_nav(); ?>
<?php comments_template(); ?>
<?php endwhile; ?>
</div><!-- #content -->
</div><!-- #primary -->
<?php get_sidebar(); ?>
<?php get_footer(); ?>
On single post apge you are already on a post. 在单次发布中,您已经在发布中。 You do not need this loop.
您不需要此循环。 You can access the data of the post for example like this:
您可以像这样访问帖子的数据:
<?php get_header() ?>
<div id="post-<?php the_ID(); ?>">
<h1 class="entry-title"><?php the_title(); ?></h1>
<?php the_content(); ?></div>
</div>
<?php get_footer() ?>
Btw. 顺便说一句。 you also missed "
<?php
" in the beginning of the first line. 您还错过了第一行开头的“
<?php
”。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.