A
A
Alexander Sinitsyn2015-12-01 21:18:51
WordPress
Alexander Sinitsyn, 2015-12-01 21:18:51

How to get to wordpress category?

How to check in the single template which categories a post belongs to? It seems that I have already gone through all the functions, but all return an empty array or a null value. Maybe I'm calling something wrong ...
Maybe it will help.
...../wp-admin/edit-tags.php?taxonomy=products&tag_ID=6&post_type=catalog

Answer the question

In order to leave comments, you need to log in

2 answer(s)
P
Pavel Torbeev, 2015-12-01
@glizer

And even get_the_category() doesn't work?

A
Alexander Sinitsyn, 2015-12-02
@a_u_sinitsin

Found ID like this

$category =  get_the_terms($post->ID, 'products');
$cat_ID = $category[0]->term_id;

If anyone knows how to simplify, write.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question