I'm experiencing a problem with the pagination of my custom taxonomies which lead to a 404 instead of the taxonomy-product_brand.php template
Here is some code:
add_action('init','init_product_brand_taxonomy');
function init_product_brand_taxonomy() {
// Labels
$labels = array(
'name' => __('Product brands','framework'),
'singular_name' => __('Product brand','framework'),
'search_items' => __('Search a brand','framework'),
'all_items' => __('All brands','framework'),
'parent_item' => __('Parent brand','framework'),
'parent_item_colon' => __('Parent brand:','framework'),
'edit_item' => __('Edit brand','framework'),
'update_item' => __('Update brand','framework'),
'add_new_item' => __('Add new brand','framework'),
'new_item_name' => __('New brand','framework'),
'menu_name' => __('Brands','framework')
);
// Arguments
$args = array(
'hierarchical' => true,
'labels' => $labels,
'show_ui' => true,
'query_var' => true,
'rewrite' => array('slug' => 'products/%product_category%')
);
// Register taxonomy
register_taxonomy('product_brand',array('product'),$args);
}
and the function to replace the %product_category%:
add_filter('term_link', 'filter_term_link', 10, 2);
function filter_term_link($link, $category) {
if ($cats = @get_the_terms($post->ID, 'product_brand'))
$link = str_replace('%product_brand%', array_pop($cats)->slug, $link);
if ($cats = @get_the_terms($post->ID, 'product_category'))
$link = str_replace('%product_category%', array_pop($cats)->slug, $link);
return $link;
}
The point is that when I'm trying to add the pagination (posts_per_page=5 for instance), wordpress throws a 404 page instead of the right template:
this page: /products/kits-batterie/agean is working
this page: /products/kits-batterie/agean/page/2 is not working
Have you got any idea ?
Thanks!
** UPDATE **
Interesting thing, I've got another taxonomy on which I thought the pagination what working because it's not nested in another taxonomy. I figured that it was working ONLY if there is no dash in the taxonomy name
For instance: /brands/abcde/page/2 is working when /brands/abc-de/page/2 is going to the 404 template.