0

i usually add rewrite rules for custom pages like this:

add_rewrite_rule('^deal-purchase?','index.php?is_purchase_page=1&post_type=page','top');

However on a site im working on now, the above just redirects to the home page whereas if i create a custom post type and reference that:

add_rewrite_rule('^deal-purchase?','index.php?is_purchase_page=1&post_type=market','top');

it works. Anyone any ideas what might be causing the 1st code to fail?

1

The second one works because post_type=market triggers the market post type archive.

Pages have no archive, so post_type=page in the first example doesn't point to a valid destination.

Rewrite rules have to ultimately result in a successful main query.

For a specific page, you could use page_id or pagename.

  • thanks for that! I'm actually not creating pages so no page_id exists. So what i do is set a query var and then return the template path to a php file. Is there a better way to directly point to a php file without creating a posttype to use in the rewrite rule? – David Oct 25 '14 at 23:06
  • check out this answer. – Milo Oct 26 '14 at 0:13

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.