2017-05-04 22 views
1

表示する各投稿の正しい日付を取得するのに問題がありました。私は '新しいWP_Query'を使用していても、最初のエントリの日付を表示しています。Wordpress投稿のカテゴリと正しい日付を表示

また、表示するカテゴリの種類を取得できません。あなたは、それは、各記事が表示されますので、

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

に変更してください

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

で "ID" を見逃している

<?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();?> 

答えて

0

をさかのぼり
関連する問題