Wrap group of wp query posts to parent div by date/year

This cannot be done only by querying database. Firstly, you have to iterate through all items and create array of posts grouped by dates. $args = array( ‘posts_per_page’ => -1, ‘post_type’ => ‘event’, ‘meta_key’ => ‘event_date’, ‘orderby’ => ‘meta_value_num’, ‘order’ => ‘ASC’ ); $wpquery = new WP_Query($args); $posts = $wpquery->get_posts(); $ordered_posts = array(); foreach ($posts … Read more

complex query question

It’s pretty easy actually in your single-event.php file within the content loop. add this loop where you want your speakers information to show. $event_title = get_the_title(); // This is the title of the current single event page we are on. $args = array( ‘meta_key’ => ‘event_name’, // the name of your custom field ‘meta_value’ => … Read more

Fetch only categorized posts

category__not_in is a private query var. This means you can only use it when constructing a query in PHP, not in a url. You would have to construct your own custom public query var and bind that to a filter that reads the category and then changes the query accordingly.

Create custom order sortby based on array of id

It looks like you want to order by post__in: $samp = array ( ‘post_type’ => ‘product’, ‘posts_per_page’ => 12, ‘post__in’ => $init_ids_arr, ‘orderby’ => ‘post__in’, // <– Try this to fix the order ); We might also want to skip the sticky posts with: ‘ignore_sticky_posts’ => true, If we want to display all of the … Read more