the_content()未显示任何内容

0 wordpress custom-post-type

我在尝试显示WordPress的内容时遇到一些问题。the_title()工作正常,但是即使WordPress中有内容,the_content()始终为空。是的,the_content()在循环内。我仍然不知道为什么它总是空的。

<?php if( get_the_post_thumbnail() ):?>
<?php $backgroundImg = wp_get_attachment_image_src(
        get_post_thumbnail_id($post->ID), 'full'); ?>
    <div class="img-container" style="background: linear-gradient(#1abc9c, transparent 80%),url('<?php echo 
    $backgroundImg[0]; ?>') no-repeat; background-size: cover;">

        <div class ="text-wrapper">
            <h1 class="single-blog-title"><?php the_title();?></h1>
            <h3 class="single-blog-subtitle"><?php the_secondary_title(); ?></h3>
            <p></p>
        </div>
        <div>

        </div>
    </div>
<?php endif; ?>

<div id="content" class="site-content">
    <div class ="single-blog-content">
        <?php if( have_posts() ): while( have_posts() ): the_post(); ?>
            <p class="blog-author">by <?php the_field('author'); ?></p>
            <h2><?php the_title();?></h2>
            <div>
                <?php the_content();?>
            </div>
        <?php endwhile; endif; ?>
    </div>
</div>
Run Code Online (Sandbox Code Playgroud)

shu*_*igo 5

您需要将内容放入循环

<?php if (have_posts()) : while (have_posts()) : the_post(); ?>
<?php the_content(); ?>
<?php endwhile; endif; ?>
Run Code Online (Sandbox Code Playgroud)