您只需在WP_Query
查询或get_posts
(接受相同参数):
$recent = get_posts(array(
\'author\'=>1,
\'orderby\'=>\'date\',
\'order\'=>\'desc\',
\'numberposts\'=>1
));
if( $recent ){
$title = get_the_title($recent[0]->ID);
}else{
//No published posts
}
(请注意,此处的“orderby”和“order”是多余的,因为它们被设置为默认值,但您可以理解)