I have my permalink set to %postname%/%location%/%course%
I want this permalink %location%/%course%/%postname%
but due to this I get 404 on every page but not on posts,
I decided to put this permalink %postname%/%location%/%course%/%postname%
but I need to strip the starting postname, in such a way I ll get no 404 pages and google will also index my site with this permalink /%location%/%course%/%postname%
without any 404
how to do this????
This is my code, for displaying custom taxonomies on permalinks
add_filter('post_link', 'location_permalink', 10, 3);
add_filter('post_type_link', 'location_permalink', 10, 3);
function location_permalink($permalink, $post_id, $leavename) {
if (strpos($permalink, '%location%') === FALSE) return $permalink;
// Get post
$post = get_post($post_id);
if (!$post) return $permalink;
// Get taxonomy terms
$terms = wp_get_object_terms($post->ID, 'location');
if (!is_wp_error($terms) && !empty($terms) && is_object($terms[0])) $taxonomy_slug = $terms[0]->slug;
else $taxonomy_slug = 'location';
return str_replace('%location%', $taxonomy_slug, $permalink);
}