0

Apologies if this has been answered already - I have singularly failed to word my question in a way that Google can help.

I'm trying to create a page that acts as a base URL for a range of items with numbers - those items won't have pages, but rather than

/page-name/?id=[0-99999]

I'd like to create

/page-name/[0-99999]

Capturing the ID number in variable form and forcing all instances with that 'page-name' to be handled by a single template. I've seen WooCommerce do something like this, and am currently searching the codebase to try and figure it out, but any pointers would be appreciated.

2

The rewrite rule already exists to handle those requests, it's for pagination of a single page post type. You can get the value of the page number with get_query_var('page'). You can render all pages with the same template by creating a page-{page-name}.php template file.

  • Thank you - appreciated. Follow up question: any idea how you'd detect a worded child rather than a numbered one? – George Pearce May 25 '15 at 14:55
  • 1
    you'd have to add your own rewrite rule. there should be some questions/answers here regarding that, if you look around. – Milo May 25 '15 at 15:10

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.