get_previous_post

函数
get_previous_post ( $in_same_term = false, $excluded_terms = '', $taxonomy = 'category' )
参数
  • (bool) $in_same_term Optional. Whether post should be in a same taxonomy term. Default false.
    Required:
    Default: false
  • (int[]|string) $excluded_terms Optional. Array or comma-separated list of excluded term IDs. Default empty.
    Required:
    Default: (empty)
  • (string) $taxonomy Optional. Taxonomy, if $in_same_term is true. Default 'category'.
    Required:
    Default: 'category'
返回值
  • (WP_Post|null|string) Post object if successful. Null if global $post is not set. Empty string if no corresponding post exists.
定义位置
相关方法
previous_postget_previous_post_linkget_previous_posts_linkprevious_postsget_previous_posts_page_link
引入
1.5.0
弃用
-

get_previous_post函数是WordPress的一个函数,用于检索一个特定文章类型的前一个文章对象: 这个函数需要一个关于文章类型的可选参数,并返回前一个文章对象。

检索与当前文章相邻的上一篇文章。

function get_previous_post( $in_same_term = false, $excluded_terms = '', $taxonomy = 'category' ) {
	return get_adjacent_post( $in_same_term, $excluded_terms, true, $taxonomy );
}

常见问题

FAQs
查看更多 >