idunn0e
idunn0e

Reputation: 51

How to access the names of the category name in Wordpress?

I'm trying to get the category name via the_slug() but I can't get it displayed via several methods. Does anyone know what's the right term?

Upvotes: 3

Views: 110

Answers (2)

Dave L
Dave L

Reputation: 411

So you have the slug but want to get the name?

$_cat = get_category_by_slug('category-slug'); // Returns Category Object
$_category_name = $_cat->name;

Source

Upvotes: 3

Stanimir Stoyanov
Stanimir Stoyanov

Reputation: 1916

You should use get_term_by. Example:

$term = get_term_by( 'slug', $value, $taxonomy );
echo $term->name;

Upvotes: 4

Related Questions