0

I have created a custom taxonomy brands and added some brands to various posts. I also created a file called taxonomy-brands.php and it seems to be working fine. If I visit www.domain.com/brands/adidas then I can see all the adidas branded posts.

However when I visit www.domain.com/brands/ I receive a 404 error. I would like this page to show all the available brands. (adidas, nike, asics etc)

Please help Richard

0

Create a page with slug 'brand'. Then create a custom page template and write required loop to return the terms of the 'brand' taxonomy. Assign that page template to 'Brand' page.

Visit this codex page to know how to code a page template.

And here is an example of how to list terms of custom taxonomy:

$args = array( 'hide_empty=0' ); //this will make sure no term is hidden. Even if empty term.

$terms = get_terms( 'my_term', $args ); // replace 'my_term' with your taxonomy.
if ( ! empty( $terms ) && ! is_wp_error( $terms ) ) {
    $count = count( $terms );
    $i = 0;
    $term_list = '<p class="my_term-archive">';
    foreach ( $terms as $term ) {
        $i++;
        $term_list .= '<a href="' . esc_url( get_term_link( $term ) ) . '" alt="' . esc_attr( sprintf( __( 'View all post filed under %s', 'my_text_domain' ), $term->name ) ) . '">' . $term->name . '</a>';
        if ( $count != $i ) {
            $term_list .= ' &middot; ';
        }
        else {
            $term_list .= '</p>';
        }
    }
    echo $term_list;
}

Here is the reference for more details about get_terms()

| improve this answer | |
  • Thanks for this reply, sorry for my delay. This seems to work perfectly however how would I split the taxonomies into an A to Z type of listing? – Richard Ascough Sep 25 '17 at 10:25
  • You want to filter via alphabet ? Like on that archive page there will be a A to Z bar when user clicks a letter s/he will get items that has that clicked letter at start on the name right? – Sabbir Hasan Sep 25 '17 at 11:38
0

WordPress doesn't automatically generate a template listing terms for a taxonomy. Your best bet would be to create a Page at the url /brands/ and assign it a custom page template. In that template you could write a query to list all your terms for that taxonomy.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.