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

Doing something wrong, can't figure out what..Any help is highly appreciated for sure!

I have a custom post type which I want to add query vars to in permalink structure.. So far so good....

This is wordking right: http://allehondenrassen.nl/kennel?artist=queen&genre=pop

This is not working: http://allehondenrassen.nl/kennel/queen/pop/

in my archive-kennels.php I added:

echo get_query_var('artist');
echo get_query_var('genre');

In functions.php I added:

add_filter('page_rewrite_rules', 'dvd_rewrite_rules');
function dvd_rewrite_rules($rules)
global $wp_rewrite;
// custom post type name
$dvd_post_type = 'kennels';
$dvd_rule = array(
    // Custom Rewrite Slug = kennel
    'kennel/(.+)/(.+)/?' => 'index.php?post_type=' . $dvd_post_type . '&artist=$matches[1]&genre=$matches[2]'
return array_merge($dvd_rule, $rules);

add_filter('query_vars', 'dvd_query_vars');
function dvd_query_vars($vars)
$dvd_vars = array(

return array_merge($dvd_vars, $vars);

Playing with this for hours but can't see the problem... Thanks in advance! Bas

share|improve this question
I have not looked in-depth into your code. But have you flushed your rewrite rules? Settings > Permalink > Save Changes – imHavoc Nov 27 '11 at 0:24

Yes I did, didn't help but thanks anyway! I fixed it by installing the dump environment plugin http://wordpress.org/extend/plugins/dump_env/

This way I was able to evaluate all existing rewrite rules. My custom rewrite rule was conflicting with an existing rewrite rule that WP generated for the custom post type by default.

I changed my rule

'kennel/ras/(.+)/(.+)/?$' => 'index.php?post_type=' . $dvd_post_type . '&artist=$matches[1]&genre=$matches[2]'

Now it works as it should! The dump env plugin, this is going to save me some development time in the future ;) Thanks!

share|improve this answer
You should also consider modifying your regex, It's going to behave unexpectedly. Better: ^kennel/ras/([^/]+)/([^/]+)/?$ – chrisguitarguy Apr 6 '12 at 2:41

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.