WordPress单篇文章分页,获取总页数代码

原梓番
原梓番
管理员
827
文章
0
粉丝
常用教程评论3,285阅读模式

	<?php 
/YuanZiFan Add Code 加总页数
			$TheURLforthisPage=$_SERVER['REQUEST_URI'];
			$arrayForPageNum=explode('/', $TheURLforthisPage);
			$CurrentPageNum=end($arrayForPageNum); 
			$CurrentPageNum=$arrayForPageNum[3];
			$RedirectURL="/".$arrayForPageNum[1]."/".$arrayForPageNum[2]."/";//除了页面以外的地址
			if ($CurrentPageNum=='') {$CurrentPageNum=1;}
			$allcontentthispage=$post->post_content;
			$pagenavCode = 'nextpage';
			$total_Page_nums=substr_count($allcontentthispage,$pagenavCode);
			$total_Page_nums=$total_Page_nums+1; 
			//YuanZiFan Add Code 加总页数
			?>

主要是同构‘NextPage’来拆分页面。判断多少个nextPage,页码数就是多少。
通过URL中的地址段,获取URL中的页面信息,得知当前是第多少页。文章源自原紫番博客-https://www.yuanzifan.com/54463.html 文章源自原紫番博客-https://www.yuanzifan.com/54463.html

站长微信
扫码添加(注明来意)
weinxin
Yuanzifan99
微信号已复制
原梓番博客公众号
博客内容精选
weinxin
原梓番博客
公众号已复制
 

发表评论

匿名网友
确定

拖动滑块以完成验证