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

常用教程评论2,299阅读模式

	<?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

 

发表评论

匿名网友
:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:
确定

拖动滑块以完成验证