You need custom rewrite rules. Add them with add_rewrite_rule(). You would provide a regexp that matches the URL pattern you want. The rewrite process will take the matches in the regexp and map them back to an equivalent URL with query vars. This URL is used internally, it does not appear anywhere externally.
Hello @bcworkz ,
Thanks for your reply,
Actually I am very new to all these.
Can You help me with a sample rewrite rule base on the URL an parameters I have mentioned here??
Thanks in advance.
This example from the doc page’s user notes that I linked previously is pretty close to what you want (modified to better fit your situation):
function custom_rewrite_rule() {
add_rewrite_rule('^([^/]*)/([^/]*)/([^/]*)/?','index.php?name=$1&sid=$&cid=$3','top');
}
add_action('init', 'custom_rewrite_rule', 10, 0);
This will match any 3 term URL, which could possibly conflict with other URLs. You may need to add a fixed value into it to match against to avoid conflict. Add the code to a custom plugin or your theme’s (preferably child theme’s) functions.php. After adding, visit the permalinks settings screen to cause a new set of rules to be generated. No need to save or change anything there, loading the screen is enough.
If you want a better understanding of the regexp, a site like regexr.com will help you. You can hover over different parts and a brief explanation will explain what’s going on. Paste our regexp into the expression field and add some example URLs to the text field immediately below. Because the site uses slashes as delimiters and you cannot alter this, you will need to escape all slashes in our regexp by placing a backslash in front of each slash.
Escaped slashes are acceptable in the rewrite rule regexp, but are not required because WP uses different delimiters. I avoid them unless required because they confuse an already confusing expression.