Php 我想显示带有日期和标题的文章摘录

Php 我想显示带有日期和标题的文章摘录,php,wordpress,Php,Wordpress,我想显示标题和发布日期的2篇文章的摘录,代码已经完成,但它只显示了一篇文章的日期 这是代码 <div class="col-md-4"> <div class="reel-focus-blog wow slideInRight animated"> <h1>Reel Focus Blog</h1> <?php $the_query = new WP_Query( 'posts_per_page=2' ); whil

我想显示标题和发布日期的2篇文章的摘录,代码已经完成,但它只显示了一篇文章的日期

这是代码

<div class="col-md-4">
 <div class="reel-focus-blog wow slideInRight animated">
  <h1>Reel Focus Blog</h1>
   <?php
    $the_query = new WP_Query( 'posts_per_page=2' );
    while ($the_query -> have_posts()) : $the_query -> 
     the_post(); ?>
      <div class="reel-focus-blog-box">
       <h3><?php the_title(); ?></h3>
       <p class="datetime"><i><?php the_date();?></i></p>
       <p><?php the_excerpt(__('(more…)')); ?>
       <a class="read-more" href="">Read More</a></>
  </div>

  <?php
  endwhile;
  wp_reset_postdata();?>
 </div>
</div>

焦点博客

使用

获取日期()

//参数
$args=数组(
“每页帖子数”=>2,
“订单”=>“描述”,
);
//询问
$query=新的WP\u查询($args);
//环路
如果($query->have_posts()){
而($query->have_posts()){
$query->the_post();

} }否则{ //没有找到帖子 } wp_reset_postdata();
// The Args
$args = array(
    'posts_per_page' => 2,
    'order' => 'DESC',
);

// The Query
$query = new WP_Query( $args );

// The Loop
if ( $query->have_posts() ) {
    while ( $query->have_posts() ) {
        $query->the_post();
<div class="reel-focus-blog-box">
       <h3><?php the_title(); ?></h3>
       <p class="datetime"><i><?php echo get_the_date();?></i></p>
       <p><?php the_excerpt(); ?>
       <a class="read-more" href="">Read More</a></>
  </div>
    }
} else {
    // no posts found
}
wp_reset_postdata();