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

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

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

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

发表评论

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

拖动滑块以完成验证
加载中...