I don’t have a full detailed response for you, but here’s a few things I’d suggest:
1) Use template parts for each of those segments. That will help clean up the template so it’s easier to work with in the future. ( see here: https://konstantin.blog/2013/get_template_part/ )
2) You could then create a helper function for the entire query, basically get EVERYTHING, then have login in the helper function to filter the results. So that within each new template part you’d have something like this:
prefix_index_query($posts_per_page = 3, $post_status="publish")
See here: https://tommcfarlin.com/wordpress-helper-functions-for-templates/
Those two things alone will get you going in the right direction for a much cleaner file structure.
Related Posts:
- Different ‘posts_per_page’ setting for first, and rest of the paginated pages?
- How to adjust found_posts so that it accounts for offset and pagination
- WP Query with offset breaks wp_pagenavi or any pagination
- Exclude first 5 posts of specific categories in the main loop
- Custom query, works, but I get a “Notice: Undefined offset: 0…”
- Offset Page Loops and Pagination
- Storing query variable and then using wp_reset_query
- While creating Block Themes in WordPress, how can I query custom posts for an Archive view?
- How to use offset in WP_Query
- How can I fix: “Notice: Undefined offset: 0”?
- WP_Query, pre_get_posts and offset
- Why does get_posts only show results for Admins or logged-out users?
- WP_Query with offset and ‘orderby’ => ‘rand’, offset not working
- How do I rewrite this loop as a new WP_Query style-loop?
- WP_Query arguments order
- WP_Query – Adding “offset” posts to the end of the loop
- Stomping WP_Query in author archive to facilitate pagination with custom queries
- Apply query arguments after the nth post
- AJAX Breaking Offset Argument In WP Query
- Page navigation doesn’t seem to work when I add offset?
- WP_Query offset is returning post from prevois loop
- Need help understanding this WP Query [closed]
- Offset WP_Query by negative 1
- WP_Query Orderby meta_key and hide some meta_key
- setting offset to category number in archive page
- Featured Image as Background with Offset
- WordPress WP_Query offset parameter not working with search parameter
- Multiple homepage layouts as selected by user from theme options
- wp query problem
- WP_Comment_Query pagination, delving into the unknown
- Sort posts by category name and title
- Getting all user metadata from user
- ajax category filter
- Display posts the match taxonomy term linked from wp_list_categoies?
- Limit WP_Query to only X results (total, not per page)
- How to disable main query?
- Use post__in and post__not_in together?
- WP_Query on different site in a multisite setup
- How to user WP_Query to lower the number of queries
- Compile two queries to one set of results?
- how do i combine keyword search and taxonomy in a WP_query $args array Worpresss [closed]
- Sanitizing search data for use with WP_Query
- How to search by a post and a category name on wordpress at the same time?
- How to retrieve current page WP_Query arguments?
- How can I get an array of all IDs from the current queried object?
- Query post from all category with same tag on 1 pages
- How to use filter hook “the_posts” with a function that refers to $this?
- Multiple loops without repeating content
- add_actions called from functions.php not returning good values
- Multiple Search Terms WP_Query
- Show posts from a custom taxonomy on a page
- Suggestions on making this query/code more performant
- Where to put meta Keys
- Should wp_query automatic meta and term cache priming be used in an enviroment with an object caching
- wp_query with custom post type only returning last posted
- Display custom tags on pages that have a specific page parent
- Slow WP_Query with ‘OR’ on meta_query
- How to filter a query by multiple meta keys and order by other meta keys
- Multiple Orderby’s using random order WP_Query
- using pre_get_posts for search results not found
- Transient api Caches confused
- How can I override one post and make it display content for another post?
- Exclude parent with child pages from WP_Query
- Co-authors list of all posts
- Query Posts by Tag and exclude
- get_posts always returning the same number of posts = 5
- Overriding $wp_query on a template
- How to use ‘WP_Query’ or ‘query_posts’ to display content in a descending order
- How to display specific ids of posts using wp_query?
- Display count number of posts with the same specific meta_key meta_value
- Tax_Query using WP_Query not working
- How to stack name list in non-alphabetical order?
- Magazine style frontpage with multiple categories/loops and no duplicate posts
- $wp_query->found_posts not returning correct value
- Apply a custom WP_Query to the whole multisite network
- display ACF repater field in archive page
- Custom Taxonomy Archive Page to display either ALL listings or only from URL
- WordPress Query for CPT that only shows posts within radius of current user’s geolocation
- Meta query ignores multiple values of the key
- Any way to use FETCH_KEY_PAIR with $wpdb?
- Filter admin ajax data by url query
- Using a variable within the blog posts array query – posts_per_page as variable
- Complex Meta Query
- Order search results by multiple post_types
- Single query for multiple categories
- Best way to query posts and order by relevancy to query
- why default wordpress loop not working outside index.php
- Woocommerce WP_Query post__not_in problem
- Modify query to exclude certain ids and certain parents and its corresponding children
- Filter posts/pages by user_role array
- I need value of saved meta to display next to the post it is associated with
- Post Query not working after updating to 4.1
- Cannot order by in WP_Query
- Pagination with WP_Query not working
- new WP_Query based on average values of meta fields
- Can’t seem to get an else statement correct? [closed]
- query_vars category_name only display one catgory out of multiple categories
- Incorrect posts displayed on category page
- I want to capture the last day’s (today) posts in a category in the numbered order in acf
- How do I have multiple metaqueries inside one wordpress query