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
查看更多 >
闪电侠

(工作日 10:00 - 18:30 为您服务)

2025-12-14 11:36:30

您好,无论是售前、售后、意见建议……均可通过联系工单与我们取得联系。

您也可选择聊天工具与我们即时沟通或点击查看:

您的工单我们已经收到,我们将会尽快跟您联系!
取消
选择聊天工具: