How Do I Add Parameters to WordPress URL?

Adding Parameters to WordPress URLs

When you create a WordPress post or page, the default URL is http://localhost/WordPress/wp-content/themes/yourtheme/yourpost.php?post=1.

You can change the URL by using the post_type or tax_terms filters. For example, to access your post from http://localhost/WordPress/wp-content/themes/yourtheme/yourpost.php?post=1&tax_term=test, you would use the post_type filter:

add_filter( ‘post_type’, ‘my_post_type_filter’);

You can also use the tax_terms filter to change the URL to http://localhost/WordPress/wp-content/themes/yourtheme/yourpost.php?post=1&tax_term=test&args=1.

To change the URL for all posts of a given type, use the tax_term_output filter:

add_filter( ‘tax_term_output’, ‘my_post_type_filter’);

The URL for a post can also be changed using the get_template_part() function.

php?post=1&get_template_part=post, you would use the get_template_part() function.

The get_template_part() function takes three parameters: the post ID, the post type, and the template name. The following code example returns the post template name for a post with the ID of 1:

get_template_part(1, ‘post’);.