douweng5420 2017-12-18 12:09
浏览 53

Wordpress paginate_links - index.shtml和页码

I am using wordpress and wants to add pagination to custom posts. But I have to maintain post slug by index.shtml. I want to add pagination by index page with page number.

My current URL:

www.demo.com/demo_post/index.shtml

I want to paginate second page URL:

www.demo.com/demo_post/index-2.shtml

Any help would be greatly appreciated, I've been struggling with this. Thanks in advance!

  • 写回答

1条回答 默认 最新

  • dpf7891 2017-12-18 12:32
    关注

    Actually this index-2.shtml is considered as file name so you must have to separate this '2' or '3' or whatever index is there, from the file name. So, you can use string replace method to separate 2 from index-2.shtml, example:

    $filename = __FILE__; //return base file name e.g. index-2.shtml
    $filename = str_replace("index-","",$filename);
    $filename = str_replace(".shtml","",$filename); //this will finally return 2
    

    Now, use this '2'(index) in your pagination function argument. Hope this might help you. :-)

    评论

报告相同问题?

悬赏问题

  • ¥15 phython路径名过长报错 不知道什么问题
  • ¥15 深度学习中模型转换该怎么实现
  • ¥15 HLs设计手写数字识别程序编译通不过
  • ¥15 Stata外部命令安装问题求帮助!
  • ¥15 从键盘随机输入A-H中的一串字符串,用七段数码管方法进行绘制。提交代码及运行截图。
  • ¥15 TYPCE母转母,插入认方向
  • ¥15 如何用python向钉钉机器人发送可以放大的图片?
  • ¥15 matlab(相关搜索:紧聚焦)
  • ¥15 基于51单片机的厨房煤气泄露检测报警系统设计
  • ¥15 Arduino无法同时连接多个hx711模块,如何解决?