This if
statement is preventing you to use category-1.php
template for the parent categories:
if( 0 < $cat->category_parent )
Parent (top level) categories always have a $cat->category_parent === 0
. Remove that statement and try again, to see if this is the result you want to achieve.
Other than that, I am not really sure I understood you well. If you are wondering why not all of your posts are displayed on your template, know that by default, posts_per_page
on global queries is limited to what is set in your Settings > Reading > Blog pages show at most in the dashboard.
Related Posts:
- How to order category.php loop by ‘meta_value’?
- How to show subcategories using loop?
- Five posts from a category in footer
- How to get all unique categories for posts in loop?
- Check if loop has any categories?
- wp_query is showing posts from other categories
- WP_Query with one category in args shows other categories
- Function the_posts_pagination() not compatible with WP_Query arguments
- How can I have sticky posts while ALSO showing posts from a specific category using one WP_Query?
- Get categories within specific term
- Display 3 levels of categories on page
- I have 3 categories, i want to display on a loop the last 3 of every category
- Retrieving category pages from subcategory returns empty sets
- Create multiple sections for all categories and then queries all the posts for each of those categories
- Main loop querying current template’s info only in custom category archive pages, not my posts
- Pagination only showed when no category is set in wp_query
- Custom WP_Query id
- Best choice for multiple loop in page?
- get_template_part causes 500 error
- Finding WordPress Posts assigned to multiple categories
- WP Query – order posts by meta field first and then order the rest
- Include posts from some categories while excluding from others
- How to display the featured image for each post?
- Assign custom parameter to each post in query
- How to provide meta_key array to wp_query?
- Wp_query with 2 meta keys and array of meta values
- Adding a html class based on post count
- Combine results of multiple WP_Query to resemble single WP_Query
- Check for the main query from the template
- how to use pre_gets_posts to exclude one queried ID from homepage loop
- Trying to retrieve random post, getting a page
- Posts in loop all show the same author when there are many authors
- Exclude recently updated post from custom WP_Query using multiple loops
- get_posts output always same post
- WordPress Custom Search Form Displaying Unexpected Results
- Multiple Rows in a using wp_query
- How to use WP_Query() on single.php?
- Pagination on category.php and tag.php not working
- sort and display posts by custom field (wp-query and the loop))
- category__not_in and id values from variable
- How to create custom query by keyword in post title?
- difference between querying database and using the loop
- If have posts a week old, display, else display a different loop
- WP_Query – Adding “offset” posts to the end of the loop
- Stomping WP_Query in author archive to facilitate pagination with custom queries
- How to make posts unqueryable/unpublish posts where ACF relationship field is an unpublished post? [closed]
- Conditional operator OR not working with custom fields
- Loop increase in while loop not working
- Create a loop on my pages with new “WP_Query”
- Get posts that do not have the same tags as current
- posts archive page – closing WP_Query loop correctly [closed]
- Create a page template for “top rated posts” but show full content and not just a list
- has_excerpt() not working inside wp_query
- Daily drip of posts – based on user ‘startData’ – ordered oldest to newest
- How to add tax_query to $args with concatenation
- Should I reset $wp_query?
- Meta query compare for ID’s greater than specific ID
- WP_Query Taxonomy categories filtering
- Exclude a Woocommerce product from WP_Query
- WP ForLoop to compare meta information of posts to determine what post to display
- Hide products in uncategorized category from search results
- AJAX Breaking Offset Argument In WP Query
- WP_QUERY wrong ammount of posts
- How to add sort order to incremented and paginated category loop
- How to load a script code only in posts?
- How does WP generate the default $query in WP_Query based on the URL?
- Continue or break the while loop
- How to filter query loop block with a search string from the query parameters
- inserting content of 1 Post to in another with a template hierarchy
- how to get category`s slug in WP_Query loop?
- Loop posts based on permalink term
- Save (and exclude) posts from loop to use in another loop on page
- Get all posts with empty meta_value
- How to split a post and intercalate elements from a loop
- How to echo woocommerce category name
- How to remove only the latest sticky post from the loop
- Expecting statement error from php loop using ACF plugin
- Loop 3 posts column wise and continue the loop into same columns
- How I can repeat 2 HTML templates in a WordPress Query?
- PHP – Loop custom post type categories within jQuery Tabs
- Check if a post has term inside loop
- Do not duplicate posts with multiple categories in multiple loops
- How to display a list of posts in same child category as current post
- How to create a widget like this?
- Slider won’t work with custom query
- How do I sort this custom list of sticky posts
- Query only displays one page_id
- How to exclude a category name from showing?
- How to Order By Two Custom Fields?
- Loop categories by recent post
- How order posts from category by date and comment count?
- Display specific page (that is child) content on parent page
- Different Loop for tag pages?
- Get the child category ID of current category
- How to get posts by category and by choosing a taxonomy term?
- Ordering posts by custom field and grouped by month
- Related Posts Excluding Certain Categories
- Getting the permalink to the latest post from a category
- Pagination for custom loop on custom page template is not displaying anything
- Does putting queries within loops cause an issue on WordPress?