It will generate the structure as you have asked for.
if (is_category()) {
$this_category = get_category($cat);
if (get_category_children($this_category->cat_ID) != "") {
echo '<div id="catlist"><ul>';
$childcategories = get_categories(array(
'orderyby' => 'name',
'hide_empty' => false,
'child_of' => $this_category->cat_ID
));
foreach($childcategories as $category) {
echo '<li class="sub-cat">';
echo '<a href="' . get_category_link( $category->term_id ) . '" title="' . sprintf( __( "View all posts in %s" ), $category->name ) . '" ' . '>' . $category->name.'</a>';
echo '<p>'.$category->description.'</p>';
echo '</li>';
}
echo '</ul></div>';
}
}
Related Posts:
- Custom permalink structure leads to be 404 on pagination
- Exclude the category from the WordPress loop
- How to make child categories recognize parent’s template displays
- Completely disable categories
- get_field not displaying my custom field value
- Show div only if post is in specific category
- wp_list_categories exclude not working
- How to show a category post to a specific registered user
- Get id of category from drop down menu
- How can I only show certain posts?
- Category menu item and its last 10 posts as sub-menu
- what is the action hook code to supporting product category condition in single product page of woocommerce?
- Prevent function from triggering again when post in specific category gets another category?
- Posts from multiblt categories but featured image only in the first one, the rest to have the post title only
- Conditional Tag for sub cagtegories?
- Display only posts from referred category on date archive page
- Sort post’s categories by ID
- Add a wordpress blog to my website having users
- in_category() not working in WordPress 4.9.7
- Set the default category of an attachment
- exclude post from displaying in loop if it is in a category, but not in many categories
- Show Featured products in product category pages
- How to remove category titles?
- Inserting Category programmatically
- Category-slug.php not being used
- Get only one of the current categories
- Show Available Taxonomy List with Current Category
- How to get grandparent of a given category
- Additional form options based on category selected not working
- Pagination for category slug returns 404 when page >= 2
- Display category-specific comments in sidebar
- Why does the argument list_only do on Walker_Category_Checklist::start_el?
- Paging not working in category.php
- Create menu / submenu from category subcategory and posts
- Display list of categories filtered by date?
- Add a custom category page in WordPress.org
- Remove the parent name from permalink
- Make parent category an optgroup
- Redirect single article permalink to paginated category page
- Exclude category by slug in pre_get_posts?
- add slug beside name in Admin Category Checklists
- How to show 5 posts from specific category on related page?
- List only categories i specify
- Author Page – List of categories plus number of posts in that category
- Exclude category from related post
- Post belonging to many categories
- On the Blogpost I have categories showing, is there a way to exclude a catgegory like ‘Media’?
- How can you access category information from a theme?
- Set category page title in custom theme [closed]
- Filter WooCommerce archive pages by an additional category
- Posts from a category on homepage with category archieves page default css
- How to use wp_list_categories with plugin category?
- Theme modification for custom category menus
- Custom css per category and per single post belong in each category
- How Do I Delete WordPress Posts Older Than 400 Days, From A WordPress Category
- Category Page Template – Can’t get category ID
- wordpress taxonomy query posts
- Filter Category Loop Dynamically
- Subcategory is displayed before Parent Category
- Shortcode to display all the post from a category in a page
- WP Category Meta plugin fix? [closed]
- How to display WooCommerce category image in my category page banner as a background?
- Order wp_dropdown_categories by ASC or DESC
- Custom Loop with certain number of one category
- “Special” category is displayed in all categories or show parent category on sub category
- How to list all subcategories from all categories but not from a certain category
- add woocommerce archive description if exist
- Can’t display posts by filtering categories using isotope.js
- Get a list of categories, separated by / to display inside the for custom metatags
- Automatically create tags and merge with categories
- Is there a reason to put a product in both the Child and Parent Categories?
- Get_term_meta() always returns false
- How to list all categories a post is in, but exclude current post´s category on single post page
- Get only children category name
- Displaying only selected categories
- No results found for second level category
- get_the_category vs wp_get_post_categories
- How to get get_categories()’s ‘hide_empty’ argument to work with global year var in the archive template?
- Getting a sub category based on a category name
- I have many different products on my website how can I get them to display under specific categories?
- Help with SQL query, how to add taxonomie terms with value stored in options?
- Categories in media library
- WordPress Shop and restricting products and categories for some users/groups
- Pass list of categories to JS
- WP url to get rss with full text of post
- Display Referring Category on single post?
- WP_query exclude a category unless it has more than one catagory
- Paginating a list of all posts collected by category titles
- Display deepest post category, when post have multiple categories
- Paginate WordPress Category Pages
- Get a list of post titles and links from yootheme master theme
- Customize category query in widget
- Page permalink rewrite
- How to control order when displaying child categories
- Broken category styling
- Link to page in category
- get_category_children/ the new get_term_children not work
- wp_list_categories() not listing categories
- List the category tree of all the product_cat categories
- Is there a function to modify existing previous/next post link without modifying theme files?