0

I'm struggling with Wordpress' rewrite function

I have the following URL structure

http://example.com/album/test-7/

'album' is the slug for the CPT single page 'test-7' is the slug for the CPT post

I'm trying to create a rewrite to allow a URL like

http://example.com/album/test-7/page/2

I'm using paginate_links() to create these links but when you visit a link with the desired structure the URL reverts to

http://example.com/album/test-7/

I've tried adding a URL tag and rewrite, but I'm very bad with both of these, here's what I have:

add_rewrite_tag('%paged%','([^&]+)');

add_rewrite_rule('^album/([a-z])/([0-9]{1,})?','index.php?p=$matches[1]&page=$matches[2]','top');

I'm not sure if I'm way off or close to getting it, but this would help clear up rewrite situations involving CPT ID's and pagination variables.

  • 1
    pagination exists for single cpt posts in the form http://example.com/album/test-7/2/ – Milo May 29 '14 at 21:07
  • Is there a pre-existing variable for this? – Austin Biggs May 29 '14 at 21:54
  • single post pagination query var is page, archive pagination is paged. – Milo May 29 '14 at 22:35

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.