WordPress keeps removing query var from the URL


I have a custom post type "press-release" that I pass a query var to the template through the URL. The URL structure looks like this.


When I go to the url everything works as expected. I am able to grab the value from the query var. The issue I have is on page load WordPress then rewrites the URL to be:


I need to keep the query var in the URL structure so people can share the URL.

I have tried many options but no success so far. Does anyone know why WordPress is doing this and how it can be fixed so my query var does not get removed from the URL?

UPDATE: I have tried this but no success

add_action('init', 'add_client_url');
function add_client_url() {
  global $wp,$wp_rewrite;
Jason 8 months 2020-11-23T16:10:21-05:00 0 Answers 11 views 0

Leave an answer