简体   繁体   English

如何显示Wordpress页码和总页数(即第1页,共3页)

[英]How to show Wordpress page number and total number of pages (i.e., page 1 of 3)

I would like to display the page numbers in index.php, search.php and archive.php 我想在index.php,search.php和archive.php中显示页码

As far as I'm aware, the variable $page contains the current page number, this works, but I just need the number of pages. 据我所知,变量$ page包含当前页码,这可行,但是我只需要页数。

Also is there an easy way to get the URL for the next page and previous page for use any way you wish? 还有没有一种简单的方法可以获取下一页和上一页的URL,以便以您希望的任何方式使用? next_posts_link(); next_posts_link(); and previous_posts_link(); 和previous_posts_link(); don't seem to be able to do what I want. 似乎无法做到我想要的。

Thanks. 谢谢。

You can use (or look at the source of) this plugin: 您可以使用(或查看其来源)此插件:

WordPress > WP Page Numbers WordPress> WP页码

I agree that there should be something similar to the $page variable. 我同意应该有类似于$ page变量的内容。 But if it's not in the WP codex, you could dive into the wonderful world of Custom Queries . 但是,如果它不在WP Codex中,则可以深入了解Custom Queries的奇妙世界。

As far as I'm aware, the variable $page contains the current page number, this works, but I just need the number of pages. 据我所知,变量$page包含当前页码,这可行,但是我只需要页数。

I know that you have to count the record in global $paged 我知道您必须计算全局$paged的记录

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM