get_next_post()函数用于获取下一篇文章的信息,包括:文章内容、摘要、状态、标题、作者、发布时间等。
语法结构
get_next_post( boolean $in_same_term = false, string $excluded_terms = '', string $taxonomy = 'category' )
参数
$in_same_term 布尔值,默认值:false,是否只返回相同分类下的文章
$excluded_terms 字符串值,默认为空,需要排除的分类ID,用半角逗号分隔多个ID
$taxonomy 字符串值,默认值:category,自定义分类法的名称
实例
<?php
$next_post = get_next_post();
if (!empty( $next_post )): ?>
<a href="https://www.xuxiaoke.com/wpfunc/<?php echo get_permalink( $next_post->ID ); ?>"><?php echo $next_post->post_title; ?></a>
<?php endif; ?>
- 1、本站大部分内容均收集于网络,若内容侵犯到您的权益,请发送邮件至:service@wuyanshuo.cn,我们将第一时间处理!
- 2、本站资源所需价格并非资源售卖价格,是收集、整理、编辑以及本站运营的适当补贴,并且本站不提供任何免费技术服务。
- 3、所有资源仅限参考和学习,版权归原作者所有,更多请阅读无言说网络服务器协议。