I am struggling a bit with how to rewrite a WordPress URL.

I have two custom post types that I gave these url structures:


The goal is to have the shoe-repair URL like this:


My Problem is that there is not only /erika-mustermann/ but several other urls like /peter-parker/. But there is only one page with /shoe-repair/ (they only differ through the page parameters I've added in the template). I don't want to make a new shoe repair page for every name, I just want custom links like:


I tried several rewrite rules but I don't get anywhere. Here I thought that would rewrite the offer-page to mysite.com/offer/shoe-repair/erika-mustermann or mysite.com/offer/shoe-repair/peter-parker. But that doesn't work and only leads to an archive page


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

Thanks a lot for your help!

1 Answer 1


Why do you have a question mark here at the end, that doesn't do anything here.

You also need to add_rewrite_tag otherwise it will never work.

  • Thank you I'll check it out. That makes sense!
    – Lisa
    Jun 7, 2022 at 10:53

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.