I am trying to get the category ID of the child (no grand children) of the current category. Using below method:
$category = get_category(get_query_var( 'cat' )); // get category ID $catid = $category->cat_ID;
I can get the current category ID. However, using this in
WP_Query result in displaying the posts that are published in Parent, Child, Grand Child category.
Is there any way, to get the child category ID of the current category?
Sample category structure is as follow:
- Parent Category x -- Child One --- Grand Child one --- Grand Child two -- Child Two --- Grand Child one --- Grand Child two
once in the
Parent Category x we have the ID, now I want the
Child Category id. Once in
Child Category x, I want the
Grand Child Category id to be used in :
wordpresss/category/parent : posts published in child category wordpresss/category/parent/child : posts published in grand child category