I have the following page which contains a single post and a number of comments:


When a user posts a comment, I add meta-data to it so I can filter comments by using these URL's:

I want to use the following url's instead:

The tips page displays a list of posts based on the query string parameters.

I worked through this tutorial, which seemed to be what I needed, but when I type in my url, I get a page not found error. http://thereforei.am/2011/10/28/advanced-taxonomy-queries-with-pretty-urls/

Is this possible?

3 Answers 3


You can add a rewrite rule such as the following. Make sure to register your public query vars with WordPress so it recognizes your rewrite rule vars.

add_rewrite_rule('^(tips)/([^/]*)/([^/]*)/?', 'index.php?name=$matches[1]&id=$matches[2]&filter_id=$matches[3]','top');

add_filter('query_vars', 'foo_my_query_vars');
function foo_my_query_vars($vars){
    $vars[] = 'id';
    $vars[] = 'filter_id';
    return $vars;

Visit the Permalinks Settings page to flush your permalinks.

You can access your variables as follows:

$id = get_query_var('id');
$filter_id = get_query_var('filter_id');

Note, you're wanting to have two dynamic variables with one URI segment which won't work at all. The rewrite rule above works for tips/cat/1 (1 being the filter_id).

To test your rules, I highly recommend you to use the Monkeyman Rewrite Analyzer.

Hope this helps you out!


You can use the add_query_arg funtion:

add_query_arg('filter_id', 1);
add_query_arg('filter_id', 2);

Now the URLs read as follows:


http:// mysite/tips/dog?filter_id=2

You can get the arguments' values as follows:

$id = get_query_var('id');
$filter_id = get_query_var('filter_id');

Here is more infomation about add_query_arg


I Think you want to change the Permalink Style You can change the Permalink of your website through admin panel of Wordpress go to Wordpress and then in the sidebar menu go to setting and then there you will see a sub-menu of Permalink click it and you will see many Types of Permalinks provided by wordpress you can also make your custom permalink. Check out the Picture Hope it might help:

Permalink Settings

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.