code示例:
1<?php $args = array('numberposts' => '16','category' => '8');
2 $recent_posts = wp_get_recent_posts( $args, ARRAY_A );
3 foreach ($recent_posts as $recent) {
4 echo '<li><a href="'. get_permalink($recent["ID"]).'">'.$recent["post_title"].'</a><span class="list-meta">'. mysql2date('Y-m-d', $recent["post_date"]) .'</span></li>';
5 }
6?>
原本直接用$recent['post_date']
输出的是2014-11-11 14:30:24
这样的格式,但现在不需要时间的输出,Y.Cheung 只需要输出日期,找了一下用mysql2date函数就可以。
参考: https://codex.wordpress.org/Function_Reference/mysql2date