Custom $_Get variable to clean url in wordpress

768 Views Asked by At

I am currently working on wordpress. URL 0f site is something like this

example.com/dashboard-form/?din=random12.

I want the url to be like this

example.com/dashboard-form/random.

Thanks in advance

1

There are 1 best solutions below

0
On BEST ANSWER

To be added on init:

To register your custom variable ('din' in the question)

add_rewrite_tag('%mycustomvar%','([^&]+)');

To create a re-write rule:

add_rewrite_rule('^product/([0-9]{1,})/?','index.php?p=4&mycustomvar=$matches[1]','top')

For more please refer below link:

https://wordpress.stackexchange.com/questions/48487/how-to-retrieve-get-variables-from-rewritten-urls

Try to add rewrite rule and let me know if any query.