Devin Stone
Devin Stone

Reputation: 1

Custom Taxonomy has hypen in the variable. How can I echo it?

New php guy here, so I apologize if I'm using the wrong words or terminology.

I'm working on an old site that has a custom WordPress taxonomy:

register_taxonomy('user-categories',array('user-posts'), array(
    'hierarchical' => true,
    'labels' => $labels,
    'show_ui' => true,
    'show_admin_column' => true,
    'query_var' => true,
    'rewrite' => array( 'slug' => 'user-categories' ),
  ));

This custom taxonomy has a hyphen instead of an underscore in its name. So that means when I try to echo it the hyphen prevents me from referencing it properly like here:

echo '<li><i class="icon-heart"></i> '.$user-categories.'</li>';

In Coda 2 the hyphen turns blue and the word "categories" stops being purple (yes, I know I sound like a complete noob right now). I've looked around the net for a way to get the echo line to work, but everything I've tried has returned nothing.

Please help! Thank you!

Upvotes: 0

Views: 193

Answers (1)

Serge
Serge

Reputation: 1066

You can use something like

$user_category = get_term_by('slug', 'user-categories', 'user-categories')

Upvotes: 1

Related Questions