I registered a custom taxonomy for WooCommerce products. Additionally, I set up a page template to list up all entries of the custom taxonomy with taxonomy archive links. Now I have the problem, that the archive links are not working. I was expecting them to work similarly to the product category and product tag archive pages. Do I need to set up a custom archive page file or is there something missing in my code? Thanks for any hint or help in advance!
// Register Custom Taxonomy
function ffos_custom_taxonomy_Brand() {
$labels = array(
'name' => 'Brands',
'singular_name' => 'Brand',
'menu_name' => 'Brands',
'all_brands' => 'All Brands',
'parent_item' => 'Parent Brand',
'parent_item_colon' => 'Parent Brand:',
'new_item_name' => 'New Brand Name',
'add_new_item' => 'Add New Brand',
'edit_item' => 'Edit Brand',
'update_item' => 'Update Brand',
'separate_items_with_commas' => 'Separate Brand with commas',
'search_items' => 'Search Brands',
'add_or_remove_items' => 'Add or remove Brands',
'choose_from_most_used' => 'Choose from the most used Brands',
);
$args = array(
'labels' => $labels,
'hierarchical' => true,
'public' => true,
'show_ui' => true,
'show_admin_column' => true,
'show_in_nav_menus' => true,
);
register_taxonomy( 'product_brand', 'product', $args );
}
add_action( 'init', 'ffos_custom_taxonomy_Brand', 0 );
$args = array(
'orderby' => 'name',
'order' => ASC,
'hide_empty' => true,
);
$product_brand = get_terms( 'product_brand', $args );
if ( $product_brand && ! is_wp_error( $product_brand ) ) {
foreach ($product_brand as $brand) {
$brand_logo = get_field('brand_logo', $brand);
$brand_title = $brand->name;
$brand_link = get_term_link( $brand );
echo '<div class="small-12 medium-4 large-2 columns" >';
echo '<a href="'.$brand_link.'">';
echo '<div class="brand_logo" style="background-image:url('.$brand_logo.');" alt="'.$brand_title.'"></div>';
echo '</a>';
echo '</div>';
}
}
In the WP admin go to Settings>Permalinks and click on the button "Save Changes". Rewrite Rules had to be flushed. Now it works like a charm!