WordPress.org

Forums

Show Category title even when no posts (3 posts)

  1. Mstnorris
    Member
    Posted 1 year ago #

    How can I show the category title even when there are no posts.

    If the category has children then I would like to list the children too.

  2. gzalariya
    Member
    Posted 1 year ago #

    You can display sub category using below code

    <?php $this_cat = (get_query_var('cat')) ? get_query_var('cat') : 1; ?>
    <?php $this_category = get_category($this_cat);
    if ( $this_category->parent ) { $this_cat = $this_category->parent; } ?>
    <?php wp_list_categories('child_of=' . $this_cat . ''); ?>
  3. Mstnorris
    Member
    Posted 1 year ago #

    Where does that code go?

Topic Closed

This topic has been closed to new replies.

About this Topic