如何使用get_the_title(ID)在一个单独的文件中获得最后一篇文章的标题


wordpress, how to use get_the_title(ID) to get the title of the last post published in a separate file?

我有一个WordPress插件,我正在修改,我想回声出最后一个帖子标题名称。

我不确定我是否可以使用。

它怎么知道哪个是最后一个?

任何想法?由于

使用下面的代码:

 $args = array(
    'numberposts'     => 1,
    'offset'          => 0,
    'category'        => ,
    'orderby'         => 'post_date',
    'order'           => 'DESC',
    'include'         => ,
    'exclude'         => ,
    'meta_key'        => ,
    'meta_value'      => ,
    'post_type'       => 'post',
    'post_mime_type'  => ,
    'post_parent'     => ,
    'post_status'     => 'publish' ); 
 $posts = get_posts( $args ); 

你可以在$posts中找到文章的标题。通过更改参数列表中的order,您可以获得最近的或最近的帖子。

裁判:http://codex.wordpress.org/Template_Tags/get_posts