我正在创建一个自定义帖子类型的短码,它工作得很好,但当我试图调用时,我遇到了一个问题。特设岗位 内容在div中显示在整个短码区域之外。
add_shortcode('portfolios-list', 'pf_portfolio_list');
function pf_portfolio_list(){
$args = array(
'post_type' => 'portfolios',
);
$query = new wp_query($args);
if($query->have_posts()) :
$events .= '<div class="owl-carousel owl-theme">';
while($query->have_posts()) :
$query->the_post();
$events .= '<div class="item">
<div class="row">
<div class="col-lg-7 cust-v-align">
<div class="media-img"> '.get_the_post_thumbnail($r->ID, array(600,600)).' </div>
</div>
<div class="col-lg-5 pl-5">
<div class="project-info mt-5">'.the_content().'</div>
</div>
</div>
</div>';
endwhile;
wp_reset_postdata();
$events .= '</div>';
endif;
return $events;
}
当我使用 get_the_content() 而不是the_content()