Uff*_*ffo 3 php wordpress wordpress-theming
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();
}
Run Code Online (Sandbox Code Playgroud)