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
/%postname%/%category%/%location%/%mba_courses%
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?