When creating a plugin for WordPress, I came across the following problem:

I want to use custom URL’s for my plugin but whenever I use the following piece of code, the normal pages aren’t working anymore.

After observing, I found out the following:

  1. I do not have access to global $wp_rewrite or $wp_query variables.

  2. The code I use, is the only code that I use.

  3. htaccess has enough permissions.

  4. permalinks are set to: website/%post-name%/

I use the following code to add a product_id variable.

function products_plugin_query_vars($vars)
    $vars[] = 'product_id';
    return $vars;
add_filter('query_vars', 'products_plugin_query_vars');

After running that, no page is accessible anymore and redirects to the homepage.

Read more here: Custom permalinks WordPress


If you know the solution of this issue, please leave us a reply in Comment section, to update the question.

Related Wordpress search:

, ,

Wordpress related questions and answers: