lundi 2 février 2015

Custom Taxonomy/Post Type permalink rewrite


I am trying to rewrite my permalinks to make them flow better, but the permalinks keep throwing a 404 not found.


Original permalink structure:



http://ift.tt/1zuX6EV


Re-written permalink structure:



example.com/{'game' taxonomy}/chapter 1


Rewrite code (in functions.php)



function custom_post_link($post_link, $id = 0)
{
$post = get_post($id);

if(!is_object($post) || $post->post_type != 'woo_video')
{
return $post_link;
}
$client = 'video';

if($terms = wp_get_object_terms($post->ID, 'game'))
{
$client = $terms[0]->slug;
return str_replace('%gameTax%', $client, $post_link);
}

return $post_link;
}

add_filter('post_type_link', 'custom_post_link', 1, 3);


The links are re-written properly, but when I visit each link, it throws a 404.





Aucun commentaire:

Enregistrer un commentaire