我正试图在侧边栏上用“quote”的帖子格式发布帖子。我正在让代码吐出else语句,但到目前为止仅此而已。如果有帮助的话,我正在根主题中工作。请告诉我是否可以显示更多可能有助于您帮助我的代码:)。谢谢
<div class="sidebar-quote">
<?php
$quote = array(
\'posts_per_page\' => 1,
\'post_type\' => \'post\',
\'tax_query\' => array(
array(
\'taxonomy\' => \'post-format\',
\'field\' => \'slug\',
\'terms\' => array( \'post-format-quote\' )
)
)
);
?>
<?php
$the_query = new WP_Query( $quote ); ?>
<?php if ( $the_query->have_posts() ) : ?>
<?php while ( $the_query->have_posts() ) : $the_query->the_post(); ?>
<?php get_template_part(\'templates/content\', \'quote\'); ?>
<?php endwhile; ?>
<?php wp_reset_postdata(); ?>
<?php else: ?>
<p><?php _e( \'Sorry, no posts matched your criteria.\' ); ?></p>
<?php endif; ?>
</div>