为什么the_content在wordpress single.php中不起作用

dow*_*337 1 wordpress wordpress-theming

我的代码:

<?php if (have_posts()) : ?>
    <?php while (have_posts()) : the_post(); ?> 
        <div class="posts" id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
            <h2> 
              <?php the_title(); ?>
            </h2>
            <div class="entry">
                <?php the_content();?>
            </div>                  
        </div><!--post end-->
    <?php endwhile; ?>
<?php else : ?>
    <h3>no content</h3>
<?php endif; ?>
Run Code Online (Sandbox Code Playgroud)

我将代码放入我自定义的wordpress主题文件single.php中.为什么它不能输出帖子内容,它可以输出帖子标题.谢谢.

Dav*_*ase 8

您可以尝试以下操作,看看它是否有效 the_content

<?php echo wpautop($post->post_content); ?> // content with p tags
<?php echo $post->post_content; ?> //without p tags
Run Code Online (Sandbox Code Playgroud)

也是一种选择

<?php echo wpautop( get_the_content() ); ?> // content with p tags
Run Code Online (Sandbox Code Playgroud)

看看这是否适合你.