Today morning I updated my wordpress, everything was fine, but suddenly I came to know that if I click on any post which is not having custom taxonomies selected in it, are giving me 404 pages.
I thought this is due to some plugins, so I deactivated all the plugins, and then I checked, everything was working, then I activated one by one plugin and came to know the actual plugin due to which I was getting 404 is GD Custom Posts And Taxonomies Tools plugin, which I was using for creating custom Taxonomies.
But my other posts were working without 404, so i dig my head more into my wordpress, and came to know that my url structure is not supporting wordpress 3.1
In my permalinks structure, I am using custom taxonomies, which was working fine till wordpress 3.0.5,
My permalink structure is this /%postname%/%location%/%mba_courses%/
where location and mba_courses are my custom taxonomies,
To make this work I am using this code:
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);
}
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);
}
How can I make this work in 3.1 or is their any feature in 3.1 where I can have custom taxonomies on my permalink?