我设置了一个wp\\U查询来显示事件,如果我们有帖子,我想显示日期,如果没有,我不想显示日期。
这是我的代码:
<?php
$today = getdate();
$args = array(
\'post_type\' => \'post\',
\'category__not_in\' => \'-9\', // When live, will need to add this parameter to all of the loop in this feedLoop.php - Do not forget to include this parameter as this function is needed!!! Cat No will change when live site is up and running!!!
\'order\' => \'ASC\',
\'post_status\' => array(
\'publish\',
\'future\',
),
\'date_query\' => array(
array(
\'year\' => $today[\'year\'],
\'month\' => $today[\'mon\'],
\'day\' => $today[\'mday\'],
),
),
);
$the_query = new WP_Query( $args );
?>
<h3><? echo date(\'l, F jS\'); ?></h3> <!-- this is the date
but I do not want it to echo out three time if
there are three posts!! -->
<?php if ( have_posts() ) :?>
<? while ( $the_query->have_posts() ) :?>
<? $the_query->the_post(); ?>
<strong><em><?php the_time(); ?></em></strong> - <a href="<?php the_permalink(); ?>" class="strong"><?php the_title(); ?></a>
<?php the_excerpt(); ?>
<?php endwhile; else: ?>
<p>There are no posts or pages here</p>
<?php endif; ?>
<?php wp_reset_query(); ?>
如何查询参数以查看是否有帖子,如果有,则回显日期,如果没有则隐藏。请有人把我从痛苦中解救出来,因为我无法理解这一点,但这应该很容易吧?!!
感谢您对我的帮助!