显示类别和Wordpress帖子的正确日期

问题描述:

我无法获得要显示的每个帖子的正确日期。即使我使用了“新WP_Query”,它也会显示第一个条目的日期。显示类别和Wordpress帖子的正确日期

我也无法获得要显示的类别类型。

<?php 
$blogloop = new WP_Query(array('numberposts' => '3')); 
    $recent_posts = wp_get_recent_posts($blogloop); 
$categories = get_categories(array(
'orderby' => 'name', 
'order' => 'ASC' 
)); 
foreach($recent_posts as $recent){ 
$category_link = sprintf(
'<a href="%1$s" alt="%2$s">%3$s</a>', 
esc_url(get_category_link($category->term_id)), 
esc_attr(sprintf(__('View all posts in %s', 'textdomain'), $category->name)), 
esc_html($category->name) 
); 
    echo ' <div class="col-md-4 col-xs-12"> 
    <a href="' . get_permalink($recent["ID"]) . '"><div class="blog-item"><div class="home-blog-img" style="background-image: url('.get_the_post_thumbnail_url($recent["ID"]).')"></div><div class="home-blog-content"><h3>'. $recent["post_title"] .'</h3><p>'. get_the_date('D M j',$recent) .'</p><span> | </span><p>'. sprintf(esc_html__('Category: %s', 'textdomain'), $category_link) .'</p></div></div></a></div> '; 
} 
?> 
<?php wp_reset_query();?> 

您已经

get_the_date('D M j',$recent), 

错过 “ID” 请把它改为

get_the_date('D M j',$recent["ID"]), 

所以它会显示每个帖子日期