简体   繁体   中英

Wordpress paginate_links - index.shtml and page number

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!

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. :-)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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