The literal implementation would be to:
- Create array variable
- While looping add to it ID of each post, using term name as key (so you have array of arrays)
- After main loop check the array and query additional posts if needed, using stored IDs for
post__not_in
so there are no duplicates
Syntax will be something like this:
$post_counts = array( 'learn' => array() );
// append ID, $post_counts['learn'] will hold array of IDs
$post_counts['learn'][] = $post_id;
It might make sense however to rather loop through terms and retrieve six posts for each. It will not probably be significantly heavier computationally, but it will be simpler and easier to maintain logic.
Related Posts:
- How do I exclude a custom taxonomy from the post loop
- Display category posts grouped by taxonomy
- display posts with same taxonomy term
- Including all terms in wordpress tax_query
- Display one post from each term in a custom taxonomy [closed]
- Is it possible to sort the post based on a custom field?
- Looping Through Custom Tax Terms and Displaying All Posts For Each
- Group posts that matches a term in a loop
- Custom taxonomy template loop
- How to handle “the_terms” inside loop
- Modify main loop in taxonomy archive page
- All posts are still shown when adding category argument to query
- Operations with custom fields values in a loop
- echo current taxonomy id for this loop?
- How do I Use Multiple Loops with WP_Query?
- How to adjust code to refresh a dropdown box with tags that are active on filtered category listing
- How can marge these loop code?
- How do I display a list of posts under all hierarchical children of the current taxonomy?
- Posts in loop displaying all taxonomies
- WordPress Tag or Custom Taxonomy Return All Posts if has that Word in Post Title
- where is the 4th taxonomy terms? taxonomy terms is disaapearing in the loop
- Display all posts that use a custom taxonomy
- If Custom Taxonomy
- How can I reduce amount of ifs and else ifs in this specific block of code?
- Returning One custom taxonomy term name
- Exclude taxonomy term from all loops, but having it on widget
- Using WP_Query and Query_post for the loop?
- Loop to display ONLY custom taxonomy parent information [closed]
- Loop through custom taxanomy in post and display custom fields from posts
- List terms of custom taxonomy if matches other taxonomy
- Only display latest custom taxonomy post
- how to get the post id in the option tag
- How to get the term description in a taxonomy term archive query?
- Chaining Taxonomy Queries
- Problem with sorting in custom child taxonomy archive page
- How to add a shortcode function that returns the taxonomy slug of the actual post within the loop
- Group posts in a category based on tags in custom taxonomy
- How to loop custom posts that have an exact match in taxonomy terms?
- Get post meta value outside of the loop
- ACF – Get unique values of array
- Remove Custom metabox from particular page template is used
- Custom taxonomy shows full articles
- Is it possible to sort the post based on a custom field?
- Output slugs to use as class names for every taxonomy a post is attached to
- Multi level archive
- List active taxonomy terms
- sort Posts by custom user filed
- How to get name of custom taxonomy
- Query pages by child term
- Trying to achieve row posts below category with multiple loops in custom tax
- Custom Taxonomy + JQuery Tabs
- WordPress show posts from children terms of a taxonomy term
- Loop custom post type by taxonomy (Category)
- Get custom taxonomy value of post and output posts in same taxonomy
- How do I create a term for every value of a post meta?
- How home my code doesn’t display any feature image? Looping through post from a taxonomy and not getting feature images back
- Loop posts without any taxonomy
- How to looping taxonomy terms?
- Custom columns on edit-tags.php main page
- Is it possible to use one slug for Multiple Taxonomies?
- Is it possible to add taxonomies to user profiles?
- Get terms from multiple taxonomies
- Separator for multiple terms
- The next_posts_link() show me a aditional page in blank
- What are terms and taxonomy, how they related to post and how these three are stored in database?
- Get multiple term objects by ids
- Echo custom taxonomy term name
- How can I get WP to build a feed based on multiple taxonomy terms
- Getting the selected terms for custom taxonomies in the editor
- Set custom post type terms by id without knowing taxonomy
- How to determine the depth of a term in a custom taxonomy?
- How to add contents of a custom field to a taxonomy term list?
- Google Map Shortcode for Custom Taxonomy/Post Types
- How to target parent product category and its children using WooCommerce?
- How do you reorder the custom taxonomies on the right side of a custom post edit page?
- Post loop for all taxonomy terms
- Remove custom taxonomy column from my custom post type columns
- Check if custom taxonomy has posts with get_categories()
- Remove a href from this code
- How to get list of only custom taxonomies?
- Replicate Drupal form options as taxonomies?
- Listing only custom post types with two required categories?
- custom taxonomies label in hebrew
- filter for thumbnail not working for custom taxonomy term
- Custom taxonomy only gets saved in quick edit
- Get tags name under custom taxonomy in wordpress
- Show message if term slug changed
- Unable to create a new taxonomy
- Code inside conditional is_tax() only working when term has posts
- Change link of taxonomy when get_the_term_list( is used?
- Get link for taxonomy to show top-level terms
- Invalid taxonomy with custom script
- Passing a variable to register_taxonomy()
- Gravity prerender taxonomy [closed]
- One taxonomy template for all categories?
- Error in Custom Taxonomy UI
- Remove ‘portfolio’ from URL
- Add Gutenberg editor to edit taxonomy (category) page
- post_type_link not working for posts without terms
- Why my archive title isn’t showing?