WordPress函数:get_previous_post_link 获取上一篇文章的链接

江河/ 2023年05月17日/ WordPress/ 浏览 982

函数原型:


get_previous_post_link( string $format = '« %link', string $link = '%title', bool $in_same_term = false, int[]|string $excluded_terms = '', string $taxonomy = 'category' ): string


获取上一篇文章的链接。参数说明可参考上一篇文章《WordPress函数:get_adjacent_post_link 获取相邻(上一篇下一篇)文章链接》


函数源码:


function get_next_post_link( $format = '%link »', $link = '%title', $in_same_term = false, $excluded_terms = '', $taxonomy = 'category' ) {
	return get_adjacent_post_link( $format, $link, $in_same_term, $excluded_terms, true, $taxonomy );
}


可以看出,函数 get_previous_post_link 就是调用了一下函数 get_adjacent_post_link ,并给参数都设置了默认值,让我们使用更方便了一些。


发表评论

暂无评论,抢个沙发...

客服 工单