K
K
kapost2020-07-01 13:42:26
WordPress
kapost, 2020-07-01 13:42:26

How to display the name of only child categories in WordPress?

It is necessary that the title and link be displayed only to the child category in which the post is located. That is, all posts are by default in the parent heading "News", but each separately belongs to other child headings, for example, "travel", "sports", etc. And so it is necessary that in the list of headings of the post only child "adventure" is displayed, but without the parent.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Sergey Ermilov, 2020-07-05
@sergeiermilov

You can also try:

<?php 
 $catsy = get_the_category();
 $myCat = $catsy->cat_ID;
    wp_list_categories('orderby=id&child_of='.$myCat); 
?>

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question