簡體   English   中英

wordpress,如何使用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

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM