WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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?

share|improve this question

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!

share|improve this answer

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

share|improve this answer

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

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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