开发者

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

i have a WordPress plugin that i am modifying and i want to echo out the last post title name.

I am not sure if i can use .

How will it know which one is the last one?

an开发者_开发知识库y ideas? Thanks


Use below code:

 $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 ); 

you can find post's title in $posts. By changing order in argument list, you can get most recent or most last post.

Ref: http://codex.wordpress.org/Template_Tags/get_posts

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜