自从evasmat_posted_on()
是主题中的函数,无需使用get_post_meta
获取日期。您可以直接调用该函数,以便:
function evasmat_posts_shortcode(){
$q = new WP_Query(
array( \'orderby\' => \'date\', \'posts_per_page\' => \'4\')
);
$list = \'<div class="cards">\';
while($q->have_posts()) : $q->the_post();
$list .= \'<div class="card">\' . get_the_post_thumbnail() . \'<h2 class="entry-title-index"><a href="\'.get_permalink().\'">\'.get_the_title() .\'</a></h2>\' .\'<div class="entry-meta">\' . evasmat_posted_on() .\'</div></div>\';
endwhile;
wp_reset_query();
return $list . \'</div>\';
}
add_shortcode(\'recent-posts\', \'evasmat_posts_shortcode\');