That way won’t work as you have found out it will grab just the 4 posts from the loop.
To do this you need to do a search of each post type, something like below will work:
$terms = array('post', 'mixes', 'artists', 'releases');
if ( !empty( $terms ) && !is_wp_error( $terms ) ){
foreach ( $terms as $term ) {
$my_query = new WP_Query('posts_per_page=1&post_type=".$term);
while ($my_query->have_posts()) : $my_query->the_post();
echo "<h2>'.$term.'</h2>';
echo '<ul>';
echo '<li>'.get_the_title().'</li>';
echo '</ul>';
endwhile; wp_reset_query();
}
}
That should do the following:
Post Type 1
– post title
Post Type 2
– post title
Post Type 3
– post title
Post Type 4
– post title
Related Posts:
- Display Authors Comments on Profile Page
- Get Custom post with ID
- Category as Class for Custom Post Type
- WP_Query to loop a Custom Field, Custom Post Types do not show
- Posts in Multiple Columns and Rows with one single loop
- Alphabetical sorting of custom post type – one letter per page
- List all posts in Custom Post Type but group dynamically by Custom Taxonomies
- How to show posts from multiple post types in a single loop? And display them separately on the same template
- How to display the rest of categories on Portfolio filterable
- WooCommerce – Show orders for a specific product ? [closed]
- Get_post_meta() won’t return value
- Query Custom Post by Category
- How to get current post id of a custom post type in a loop using template singel-{custom type}.php?
- ‘category__and’ for custom taxonomy?
- WP_Query and using a variable for ‘cat’=> in the args array = WP Bug?
- Separate Posts and Custom Post Type in Custom Taxonomy archive template
- Why does using WP_Query inside a shortcode in an elementor page cause the arguments for WP_Query to get malformed?
- get_template_part for custom post type content not working
- How would I create a shortcode to display a custom post within a page or regular post?
- Creating Accordians in WordPress Theme
- How to insert content from another Custom Post type into Post?
- Display different content on homepage depending on post type
- Only show posts from a certain category?
- How i can add ‘N’ page of ‘N’ pages under posts loop?
- WP_Query orderby modified to include custom meta changes
- get_attached_media() on author page not working
- Calculate all custom field values in the post loop
- I would like to have different styles for my posts based on the content of each post
- Checking if Post Title is Unique as Loop Criteria
- Custom post type multiple loop by taxonomy term
- List custom taxonomy specific to one custom post type
- Custom post type, organized by categories
- What’s the WP way to load remaining custom posts?
- What to and how to proceed with CPT to make DB small and efficient?
- A custom post within a custom post
- Custom post type conditional in loop
- get_the_title() is returning results from previous loop
- How can I group posts by months and years?
- Trying to Create a PHP Variable for post_type that can be referenced Site Wide
- 3 random images from custom post type, each in a div with a diffrent class
- Displaying multiple post types on home page
- Shortcode leaves no space for other elements?
- Query to get child pages of current page and display it in action hook
- Add more than one custom post type to wordpress home page post loop
- Get post format
- Trying to add a class to post links
- Display post from custom post type
- Use post in multiple places on a page with multiple posts
- List all Custom Post Type posts excluding certain Taxnomy term
- WordPress giving a 404 page when passing a year argument different than the current year
- Add Class according to the order of appearance
- Compare Two Custom Post Types Using The Same Custom Taxonomy
- Permalinks for single-[custom-post-types] not working
- Loop and add Specific Categories and Products Images
- Drop down list with posts within the “add new” page
- How to show custom post type on homepage and in categories
- using the loop in custom meta is messing up ‘add new’ post type
- How can I increase the post count for custom post types only?
- Custom post type pagination error
- How can I loop at a Specific Taxonomy from a custom post type?
- Custom archive page for custom taxonomy and pagination issue
- Update query based on CPT / Post Type, show all sorted by date
- Custom post type paging return home page
- WordPress next post by ajax call on button click
- when looping through custom post data not appearing
- How to avoid duplicate posts queried from custom meta?
- Multiple Loops In Tabs Only Displaying First Loop
- How to only get the content of post page while looping?
- Why do my custom post type show up in all pages?
- ACF meta_key and meta_value break loop
- Looping to organize and display custom posts by category using PHP and WordPress
- Pagination for a cpt filtered with a category
- Staggering featured post using ‘sticky’
- My post loop needs to have 8 different post templates
- Mix Facebook and Twitter feed into custom posts
- Sort loop by custom field from different post type
- next_posts_link() always generates second page link on custom post type
- Infinite scroll doesnt work
- Show posts for current taxonomy
- Excluding category from loop not working
- Strange behavior on WP_query
- WordPress loop, show only one post per custom field
- How to check if meta box value is false for all posts then do something based on that
- Tricky Custom post loop
- Custom taxonomy page template
- display news with pictures 3 small and one large (loop)
- Loop multiple taxonomy in custom post
- $post breaking container loop
- Posts without featured image using other post’s featured image
- Get result from Custom Field in Custom Post type
- Nested loop called with shortcode duplicating the content above the main loop
- Custom post-type’s pagination not working in category.php
- Pulling in a particular post into a single page based on the post id passed into the code
- why get_post_meta is returning 0?
- Get Posts From A Certain Post Type In An ID Array
- display custom post type from register taxonomy
- Custom post type and have_posts() return empty result
- Show search for data extracted from metabox
- Get all active posts that are tied to a custom taxonomy for a custom post type
- Best practice to display a list/archive of Custom Posts in a Page Template