user3256401
user3256401

Reputation:

How to get the custom category slug and id from custom post type?

I have a custom post type. It's have a custom category / taxonomy. It's name is download_category i.e register_taxonomy( 'download_category',.....

I need know the custom category id and slug of a particular post in custom post type.

For example if 120 is my custom post type id then how i get the taxonomy of custom post type under download_category taxonomy . Please help

Upvotes: 0

Views: 2757

Answers (2)

Sagin
Sagin

Reputation: 1019

$terms = get_the_terms(120, 'download_category' );

print_r($terms );

see the result .

Upvotes: 1

Amit Mishra
Amit Mishra

Reputation: 291

By using

get_the_terms( 120, $taxonomy );

get the taxonomy of custom post type

Upvotes: 0

Related Questions