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 Answer 1

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.

2
  • 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
    Commented Oct 25, 2014 at 23:06
  • check out this answer.
    – Milo
    Commented Oct 26, 2014 at 0:13

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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