Get Category from Post


right now i am getting the category with this Code:

if (get_the_category( $id )[0]->name == "catname") {


but with this Method i only get ONE Category, even if i change the 0to 1or any other number. I tried the same method with:

if (wp_get_post_categories( $id )[0]->name == "catname") {


but this has the same effect, i can only get one categoryname or ask for one specific.

The Post i am using has 3 categories.

How can i get the other categories? Or how can i ask for the other categories(with if)

, , , yama_HD 4 years 2020-03-26T12:51:46-05:00 0 Answers 108 views 0

Leave an answer