描述
获取下一篇文章
语法
get_next_post( bool $in_same_term = false, array|string $excluded_terms = \'\', string $taxonomy = \'category\' )
参数
$in_same_term:(bool) (Optional) (Default value: false) 是否限定在同一分类目录
$excluded_terms:(array|string) (Optional) (Default value: \’\’) 排除分类的id
$taxonomy:(string) (Optional)(Default value: \’category\’) 如果 $in_same_term 设置为true 表示限定的分类
返回值
WP_Post:如果成功,返回文章对 象。
Null:如果 global $post 没有设置,返回空值Null。
String:如果不存在符合条件的文章 ,返回空字符串。
示例
$next_post = get_next_post();if ( is_a( $next_post , \'WP_Post\' ) ) : ?> <a href=\"<?php%20echo%20get_permalink(%20$next_post->ID%20);%20?>\"><?php echo get_the_title( $next_post->ID ); ?></a><?php endif; ?>
相关
调用
wp-includes/link-template.php:get_adjacent_post
被用
wp-includes/deprecated.php: next_post()
源码
位置:wp-includes/link-template.php
function get_next_post( $in_same_term = false, $excluded_terms = \'\', $taxonomy = \'category\' ) { return get_adjacent_post( $in_same_term, $excluded_terms, false, $taxonomy );}
© 版权声明
THE END