PHP Print selected categories of the Array
-
Hi !
I’ve the following code in attempt to print the second top category and the category of a search result:
$category = get_the_terms( $post_id , 'manualknowledgebasecat'); $number = $category[0] -> term_id; echo get_category_parents( $number, true, ' » ' );The previous code print the complete list of categories, but I only want it to print the second category and the current category. For example: If a search result has this categories: Products >> NameOfTheProduct >> Manual >> Configurations
I just want to print the NameOfTheProduct and Configurations. How can I get to do that ?Thank you por you replies in advance.
Best regards.
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
The topic ‘PHP Print selected categories of the Array’ is closed to new replies.