Your code checks for child categories and shows them if they exist, but you aren’t then going on to process the loop that would ordinarily display the posts in the current category.
You want to extend your code to be of the form:
if ( is_category() ) {
$this_category = get_category($cat);
if ( get_category_children( $this_category->cat_ID ) != "" ) {
// display the list of child categories as you currently do
} else {
/* run the standard loop to show the posts using
whatever loop code your other templates use
*/
}
}
Related Posts:
- WordPress Multiple Category Search
- get all tags from category
- How can I add the featured image functionality to a custom taxonomy?
- Display all posts from all categories with pagination
- Changing Top Level Items into Radio Buttons in the Categories Meta Box?
- Custom post types with their own permalink structure
- How to create a widgetized sidebar for every category dynamically?
- Display the deepest child category from Category X (in loop)
- When using get_categories or similar, is it possible to filter results that contain certain Tags as well?
- Exclude subcategories from the url
- Why adding Categories does not auto refresh in Backend while using my custom theme?
- WooCommerce – Display product child categories from specific parent
- Select category in custom query
- Removed slug from CPT, now How/where do I hook the filter to the taxonomy term archive pages link?
- Show list of categories even if they have no posts
- Search by word, category, tag, author
- How to hide certain categories in wordpress dashboard?
- How to control template resolution if both Author and Category filter in place?
- How to filter archives both by category and tag?
- Resolved – category-slug.php not working after wordpress migration
- How to retain the values from dropdown category lists after wrong form submission?
- How i can let users add notes to my posts
- Format Brand value in Category view [closed]
- Get multidimensional array that reflects category hierarchy
- Single_cat_title() print the title before text
- Sort posts by post_type in category.php template
- Add Post Screen Keep Category structure
- Why would in_category only return one post in a specific category?
- getting content from main domain to sub-domain using category and WP_Query
- Possible to make a subdirectory that loops through a single category?
- editing fonts of category links from the_category() funtion
- Force a user’s posts category
- Style wp_list_categories
- Checking for two categories in query_posts
- get_the_categories filter returns an empty array
- Warn me about ‘uncategorized’ posts
- Why category.php throw 404 in wordpress while calling paginate_links()?
- How to get related tags based on a category?
- Show category to visitors in different name or different language without changing basic category
- How to get latest posts from each category in regular order
- Pagination for ajax category filter
- Get posts from specific taxonomy term
- limit a list of tags to one category [closed]
- How many categories can WordPress handle before performance suffers?
- WordPress Drop down category as array for using in page builder
- Get sort order of product categories
- how to wordpress When I click on the category link, subcategories appear
- Show posts in “image” format when viewed in category page, but with comments in blog
- How to pull a list of posts in a category while exluding posts in subcategories of the category
- Exclude category from query
- How to change the order of the subcategory and category in a post?
- Properly setting up a feed
- How to loop custom post_type from (a) specific category(ies)?
- Display posts of certain categories to specific user roles
- How to restrict category creation to admins only while allowing editors to still pick category
- Display Related Posts by “Category” “by Author”
- Query (built in) Categories and Advanced Custom Fields?
- Change post title if post has specific category
- Filter By Category Dropdown List With Custom Taxonomies
- query_posts by category_name and custom taxonomy
- How to schedule categories?
- Template for product-category page [closed]
- How set all posts in wordpress in one category
- custom query for both category and pages using global $wpdb;
- url for posts for a date within a category
- Autolinking keywords in text with tags
- WP E-Commerce creating categories programmaticaly [closed]
- WordPress PageNavi Plugin not working in category.php
- Different post slug based on archive
- How do I get conditional sidebars for specific category archives and posts
- Post does not show category wish just show latest post
- Show category in post page, that is in specific category
- Style post archive blog preview based on category
- Woocommerce Category Sort Dropdown
- Is there a way to ‘archive’ inactive categories?
- Getting child category id (help with improving my code)
- Assign post category to a page by selecting category from page dashboard
- Hiding by default posts in given category except for some cases
- Assign a class to first element in category in loop
- Different template for subcategories
- Hide category name using mod_rewrite
- Category page shows only 1 post when that post has more than 1 category?
- Assign a category to all articles
- Automatic Category selection
- How can I modify this code to iterate over an array of categories?
- DESC order not working when showing only child categories
- Search tag within category
- How to create category page
- Exclude Category From Home Page, Display Posts on It’s Own Page?
- Custom WordPress category page showing all posts rather than the specified category
- Add 1 category more to If_in_category statement
- How to get child category list post in one template?
- i want to add pagination list of categories
- Woocommerce custom taxonomy order
- Update wordpress menu with woocommerce products
- AZ Directory posts directory index
- Category archive page has two URLs even when default theme is active with no active plugins
- Replace category titles inside RSS feed
- How to get specific number of category post on a page or category page?
- Display different sidebar based on search results from one category