I have a custom rewrite as follows

enter image description here

So /shares points to a page I created with a slug images which uses a custom query variable named h626_page.

My problem is I want to set the images page as front page, so I go to the admin dashboard, and under Reading I set the front page to images, nevertheless, that redirects all /shares requests to /, which isn't a big deal but I lose the query variable in the process, so /shares/2 redirects to / and even if I navigate to /2 and add a rewrite rule ^/(\d+)/? pointing to the images page, it still doesn't work.

1 Answer 1


Are you sure your rewrite rules are actually being saved?

How are you calling this function to setup the rewrite rules? Action? What about flushing rewrite rules, are you flushing them anywhere in your project? Disable all of your plugins and test to make sure one isn't flushing rewrite rules on every page load.

As you can see in this plugin i'm creating: https://github.com/tripflex/wp-login-flow/blob/master/options.php

I have to call a function just to preserve the rewrite rules that normally get overwritten by poorly coded plugins, but that should give you an idea of how to setup rewrite rules.

You can also see I have lots of debug logging in there as this literally took me a full 2 days to get completely functional as rewrite rules can be tricky

Two major things that caused me problems:

  1. Poorly Coded Plugins (disable all other plugins for testing)
  2. WordPress Heartbeat (use func from code above to disable heartbeat for testing)

yes mods i know this should be in a comment but i am not able to comment so this was my only option to reply

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.