gpt4 book ai didi

php - Wordpress 我怎么知道分页是否处于事件状态?

转载 作者:可可西里 更新时间:2023-11-01 00:04:24 25 4
gpt4 key购买 nike

Wordpress 有功能或类似功能吗?我需要一种方法来检查是否有任何页面链接(旧条目 | 新条目)要显示。

最好的问候,

最佳答案

如果您查看 new_posts_link函数,你会看到一个 $max_page 和 $paged 变量。

如果$pages大于1,则有上一页链接。
如果小于 $max_page,则有下一页链接。

所以你可以执行以下功能:

# Will return true if there is a next page
function has_next_page() {
global $paged, $max_page;
return $paged < $max_page;
}

# Will return true if there is a previous page
function has_previous_page() {
global $paged;
return $paged > 1;
}

# Will return true if there is more than one page (either before or after).
function has_pagination() {
return has_next_page() or has_previous_page();
}

关于php - Wordpress 我怎么知道分页是否处于事件状态?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1588244/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com