is it possible to bring custom taxonomies to permalink?

currently my permalink is looking something like this /%postname%/%category%

but i also want to add custom taxonomies to my permalink so it should look something like this


is this possible?

the solution to this answer i found, i googled and i found this code, which works perfetc for me

add_filter('post_link', 'mba_courses_permalink', 10, 3);
add_filter('post_type_link', 'mba_courses_permalink', 10, 3);

function mba_courses_permalink($permalink, $post_id, $leavename) {
    if (strpos($permalink, '%mba_courses%') === FALSE) return $permalink;

        // Get post
        $post = get_post($post_id);
        if (!$post) return $permalink;

        // Get taxonomy terms
        $terms = wp_get_object_terms($post->ID, 'mba_courses'); 
        if (!is_wp_error($terms) && !empty($terms) && is_object($terms[0])) $taxonomy_slug = $terms[0]->slug;
        else $taxonomy_slug = 'mba_courses';

    return str_replace('%mba_courses%', $taxonomy_slug, $permalink);

but now i have one more problem, when i google my website i get the old url structure link, when i click on that i get 404 error, where as the post is still inside the website, just the url has changed, so how can i make the old url to direct it to new url i mean if clicking on the old url and instead of redirecting to 404 page, can it redirect to the actual post where i have the new url?

is this possible?

  • Supposedly this was going to be part of WordPress 3.1. However, it looks like it required some rewriting of how the entire permalink system works. I think the rewrite was done, but the upper exposing stuff was not.
    – mtekk
    Dec 30, 2010 at 1:45

2 Answers 2


What you're looking for is a 301 redirect. I use two plugins to catch do this. One notify's me of 404 errors ( http://wordpress.org/extend/plugins/404-notifier/ ) and the other makes writing the 301 redirects easy ( http://wordpress.org/extend/plugins/simple-301-redirects/ ).

You could also write the 301 redirects in your .htaccess file and dig through the server logs to find the 404 notices.

Long term you just need to wait for Google to crawl the site and find the new link structure. If other people are linking to your site from other blogs you can try and get them to fix their links but it's unlikely that you'll be able to get many people to do that.

  • this will make me mad, cause i have 1000+ posts, and for each if i keep on writing the url, it will go crazy, is there any other way to make this, cause now my about us page is also not opening my permalink structure is : /%location%/%mba_courses%/%postname% where my location and mba_courses is custom taxonomy Dec 29, 2010 at 12:29
  • Not that I'm aware of (though that doesn't mean there isn't). Permalinks are called that because they are supposed to be permanent. I've had to do the same things for a few thousand posts before and yes it does suck but it's the price of changing the permalink structure as you have done. Dec 29, 2010 at 12:39
  • You could also set the structure as you had it before and write custom permalinks for each post. wordpress.org/extend/plugins/custom-permalinks Dec 29, 2010 at 12:42
  • so it means there is no other solution rather then keep on editing each and every post url? Dec 29, 2010 at 12:42
  • There might be but we'll have to wait and see when others offer solutions. Dec 29, 2010 at 12:51

http://wordpress.org/extend/plugins/custom-post-permalinks/ does that for custom posts, I'm sure you can easily extend it to support the 'post' post-type as well.

I've used it extensively on a couple of sites and it works great.

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.