Your best bet is not to run a bunch of queries but to loop through your data once to organize it then a second time to display it. Below is the logic you need. The exact code will depend on your data set.
$events = array();
$posts = WP_Query( $args );
foreach ( $posts as $post ) {
$venue = $post->venue;
$day_of_month = date( 'd', $post->date );
$events[ $venue ][ $day_of_month ][] = $post;
}
for ( $x = 1; $x <= 31; $x ++ ) {
foreach ( $events as $venue => $ev ) {
if ( ! empty( $ev[ $x ] ) {
echo '<td>';
foreach ( $ev[ $x ] as $details ) {
echo $details;
}
echo '</td>';
}
}
}
Related Posts:
- How do I show the post title if an advanced custom field hasn’t been used?
- Should we trust the post globals?
- Get first post from wp_query
- WP_Query: Why is sticky post not first item in loop?
- Query *only* sticky posts
- How do I reorder (pop and push) items from WP_Query?
- How to exclude latest x posts from a paginated query?
- Reverse chronology of post listing
- WordPress Number of Posts Not Changing With posts_per_page
- This AJAX Code Doesn’t Work – Looking for elegant solution
- Specific loop in Shortcode
- Search widget breaks when using multiple loops?
- Converting multiple loops into one single loop with pagination
- Display posts with comments closed, with pagination?
- Group posts by year in loop
- How would I get 1 latest post from a query for 5 posts?
- Loop through all product posts?
- WP Query – duplicated posts once including tags in search results
- Display post from current category and same tag?
- Why WP_Query(‘showposts=5’) shows only 1 post?
- How do I correctly set up a WP-Query to only show upcoming event-posts?
- Blog post per page setting conflicting with custom WP_Query?
- How to exclude latest x posts from a paginated query?
- WP Query – Posts Per Page not working in combination with category__in
- Pausing and Resuming WP_Query results
- How to : pagination in 3 different custom loops on the same page
- List authors with the last post title and order by last post date
- wp_query random post
- Possible to alternate between two loops
- How to get posts published on the latest date?
- Page and post loop same template
- ACF to select posts not displaying on blog page
- Getting blog pagination to work on page set as front page
- Display current post position in Elementor Posts widget
- WP_Query: Show 10 posts in date order, first three random
- WordPress Loop: How to display recent posts in multiple divs
- Not all posts showing in query
- how to handle the loop using filling bootstrap grid structure?
- WP_Query custom field pass the post id
- Custom WP_Query not working correctly
- WP_Query of Category Not Showing First Post
- If custom field is empty, use one from a previous post
- Display 3 posts with different HTML markup using a loop
- ACF flexible content block not showing on live site (works locally)
- While loop in functions.php outputting the_title() of each post on frontpage
- Display specific posts based on an ID of another post
- Numbered Pagination Showing The Same Posts After Altering WP_Query
- show loop id post , only first id can read
- Double loop output
- Loop through all posts showing duplicates
- Wp_query loop is not working as it should
- WordPress Request Post All Post ID in a Loop? [closed]
- WordPress loop uses unmodified posts array, why?
- Advanced Post Display/Pagination/Ordering
- Why I obtain this WP_Query strange behavior trying to select posts having a specific tag?
- How to show the posts list into a static page? Problems to use the loop into a static page
- Adding a category at even positions on main loop with modified pagination
- Make assigning post to a specific category equivalent to assigning it to all categories
- First post in loop displays twice
- posts_per_page – Repeats only first posts ‘post__in’ array
- Custom post order returning posts from other categories
- Is it possible to use the_post 2 times in one loop
- Get Image tag from content of post
- Stuck in the query loop
- How safe is renovating $wp_query when doing WP_Query pagination in Page Template
- Get all fields inlcuding “ACF” (Advanced Custom Fields) columns in wp_query
- Start WP Pagination From Number 1 in URL
- Exclude the first ‘n’ number of posts of a tag from home page?
- Query posts and return XML
- how to change the number of posts returned in a specific loop without making it global?
- Query Posts With Over 1000 Views
- How to add tags (custom taxonomy) to post class css?
- posts_per_page option limits the number of Gallery items
- How to order posts by meta_value and title
- Listing Specific Categories from Current Post with Depth
- How to exclude visited posts from loop
- Use two different post_per_page limits with infinite scroll
- Saving custom fields to a custom taxonomy
- wp_posts table: safely remove unused columns to save database storage
- Query Posts by Custom Field
- How to make the first post in the loop be styled like a “new / featured” post?
- Adding a blog archive with pagination using WP_Query
- How to get Tags with specific post id
- “Right Way” to make custom Loop respect reading settings inside admin panel?
- How to setup a query to output posts by groups of five?
- Redirect to another page using contact form 7? [closed]
- Only display sticky post or latest post in custom loop
- How to order posts in an arbitrary order?
- how can i change WP main archives loop to sort by name or title
- How do I stop the loop from repeating in my category template?
- get_the_category listing in hierarchial order
- Using wp_list_pages() after calling query_posts()
- how to get post order by post id wp_query?
- How many posts does the loop return?
- Display Posts on Custom Page
- How to make a sum of all posts displayed in a loop
- Exclude current custom post on single post
- Wrong post title displayed from loop
- Nested WP_Query breaking loop
- Get Value of Post before