Issue with $term->name when Taxonomy term contains spaces
Hi, hopefully someone can help me with this…
Basically, I’m creating an archive page for a custom taxonomy (brand). I want to show the custom taxonomy term in the title. The code I’m using to do this is:
<?php $taxonomy = 'brand'; $cat_name = get_query_var( $taxonomy ); $term = get_term_by('name', $cat_name, $taxonomy); echo '<h1> All products from ' . $term->name . '</h1>'; ?>
This works fine on pages where the brand is a single word (eg. Seagate), but when the brand has two words (eg. Western Digital) it doesn’t display the term name.
Am I missing something? Is there something I need to do to make it work when term names contain spaces?
Any help is appreciated!
- The topic ‘Issue with $term->name when Taxonomy term contains spaces’ is closed to new replies.