You have the right idea.
You can start dividing this up into individual templates in order to prevent repeating yourself or having multiple templates that do the same thing.
You should use get_template_part()
to pull in different templates as you need them. This allows you to branch out your templates further without WordPress dictating how it should be done.
In your case, you may have a template for your generic loop that calls a template for individual items in a post list context that calls a template for each different type of item (your custom post type).
Related Posts:
- Pagination not working with custom loop
- Display all posts starting with given letter?
- wp_pagenavi() with custom wp_query()?
- how do I group content in magazine-style ‘issues’?
- WordPress “Loop” with large set of results
- WP_Query on custom post type not displaying, multiple loops & get_template_part
- Conditional two level dropdown filter for custom post type
- Show all custom post type posts sorted by custom taxonomy then by another custom taxonomy
- Group search results by post type, but hide post types with no results
- Custom post type loops with different page templates
- Should unaltered default loop/query return a list of custom posts belonging to a custom taxonomy?
- 404 error PageNavi custom type taxonomy | wordpress
- Query for posts in 2 taxonomies
- IF statement in a do_shortcode
- How do you output custom code between posts in the loop?
- How do I Use Nested Loops of Custom Post Types for MultiSite Blogs using WP_Query()
- Impossible to get Attachments Outside WordPress?
- How to dynamically build a multiple taxonomy query loop within a post type’s single loop?
- How to check if “is single” page
- Using pre_get_posts to filter one loop in a multiloop archive
- Custom Post Type Loop within Shortcode
- get_template_part for each level of taxonomy term
- Query custom post type in the loop
- Very Slow Page – How to Optimize # of Queries?
- Display CPT posts based on specific taxonomy
- Meta Key Value in current-user-only loop
- CPT + CMB2: data not displaying for only first post in loop
- Loop custom taxonomy to get lists of cutom post types?
- How do i calculate the total of values of custom fields in custom post types?
- Show a Category X’s custom post type on Category X archive page?
- Sort by alphabetical order archive.php page
- WP Query with categories only shows one post and ignores the category
- Displaying Custom Posts on a Page
- Custom Post Type Category Link
- Custom Post type category pages template and loop
- Three Most Recent Posts, One Per Term
- Custom Post Loop pulling all custom posts, not just one
- Wrapping x posts in html without leaving empty html
- Sort posts in loop by the WooCommerce Membership of the author
- Loop increase number
- Move Genesis Single Page/Single Post Title
- Post loop count is not in order
- hide specific div on single.php [closed]
- Looping Through Categories of a CPT
- How do you output an unknown number of images in a custom post type with desired markup?
- Get data from PHP to JavaScript to set position of each post on front page
- assign different templates to custom post type with homepage loop
- Assign a template to a custom post type when displayed by the main loop on the home page
- foreach loop inside the loop creating duplicates in output
- The loop does not show users
- Displaying information from custom field on custom post type
- Display only a single CPT
- Control Loop Within Loop
- How to fetch posts that are stored in the different table than (default) wp_posts?
- How do I enforce a specific custom post type on the loop
- CPT archive page – show one post from each taxonomy term
- How do i display post from a taxonomy term?
- Custom loop request based on custom field
- How do I list a custom field and custom taxonomies for each result in a loop?
- Show the categories the current post has
- Insert a Custom Post type into my Loop
- Custom Post Types Not Showing Up In query_posts Result
- Do I need a loop to display an object that attached to posts?
- “Order” doesn’t work in custom loop?
- Pagination not working in custom post type. Help
- Custom meta fields not showing up in WP_Response Object via custom endpoint
- How to output and alert message when updating a post
- Display all posts from specific category and CPT
- Wrapping an unknown amount of posts inside separate HTML Containers during WP_Query loop
- sorting in wp query based on custom field value
- Can I show some specific post rather than latest post?
- Custom post type loop without children
- How to display user-defined / custom post in wordpress?
- WordPress loop add heading before first of type
- Fetch loop of custom post types with AJAX
- Only show current category post
- Looping through custom taxonomy in one template
- get_post_meta for Custom Post Type ( CPT )
- How to keep a CPT stick to specific position?
- Loop posts in a table ordered by a custom field value
- Is it possible to add query parameters on the archive page?
- Custom Loop Event Page
- Cant insert wrapper div into index.php
- Custom post type archive pagination with HTML5Blank theme?
- WordPress loop for multiple custom post types
- How can I pull information from my loop and divide them seperately?
- Pagination not working with custom loop
- Fallback if statement based on the number filtered from it
- Turn post into simple slideshow
- Create custom post order (with custom post type meta)
- Pagination not working with custom loop
- Listing custom post type items from a couple of custom taxonomies
- Noob Loop Question
- Custom Post Types and 404 Pages
- Fourth page of custom post type archive page does not exist
- the_content() stop images being pulled through
- Render a loop in Timber (twig for WordPress)
- show custom post’s post in two different divs [duplicate]
- Limit wordpress posts loop to continue onto another page
- Unable to display paging navigation with a custom post type loop