\\u摘录()返回的文本不符合我的小部件格式。我无法更好地解释它,所以我将向您展示我的代码:
function widget($args, $options) {
extract($args);
$post_type = $options[\'post_type\'];
$num_of_posts = $options[\'limit\'];
// Create a new instance
$second_query = new WP_Query( array(
\'post_type\' => "$post_type",
\'posts_per_page\' => "$num_of_posts",
\'post_status\' => \'publish\',
) );
// The Loop
if ($second_query->have_posts()) :
while( $second_query->have_posts() ) : $second_query->the_post();
$byh_content .= "<p>" . the_excerpt() . "</p>";
endwhile; else :
$byh_content = "<p>No " . $options[\'post_type\'] . "s found.</p>";
endif;
wp_reset_postdata();
$title = "<h3>" . $options[\'title\'] . "</h3>";
$content = $byh_content;
echo $before_widget.$title.$content.$after_widget;
}
结果不是我所期望的。以下是渲染时的外观:
标题应位于顶部。原因是,摘录的内容不符合预期: