Limit loop to future events

Assuming your date is in the correct format for proper ordering (yyyy-mm-dd), add a meta_query to your args: $args = array( ‘post_type’ => array(‘basic_events’), ‘order’ => ‘ASC’, ‘orderby’ => ‘meta_value_num’, ‘meta_key’ => ‘date_of_event’, ‘paged’ => $paged, ‘meta_query’ => array( array( ‘key’ => ‘date_of_event’, ‘value’ => date( ‘Y-m-d’, current_time( ‘timestamp’ ) ), ‘compare’ => ‘>’, ‘type’ … Read more

Query Posts that have Custom Taxonomy

Got help on Facebook and just needed to change this: <option value=”<?php echo $term->name; ?>” <?php if($_POST[‘mealtype’] == $term->name) { echo ‘selected’; } ?>><?php echo $term->name; ?></option> to this: <option value=”<?php echo $term->slug; ?>” <?php if($_POST[‘mealtype’] == $term->slug) { echo ‘selected’; } ?>><?php echo $term->name; ?></option>

WP_Query will not display draft posts

You can just ‘post_status’ => ‘any’. Here is the completed code. global $wp_query; $ids = array(130,132); $args = array( ‘post_status’ => ‘any’, // ‘post_status’ => ‘any’, // same output ‘post__in’ => $ids, ‘post_type’ => ‘alpha’ ); $q = new WP_Query($args); foreach ($q->posts as $post) { echo $post->id; } Official docs on post_status option https://developer.wordpress.org/reference/classes/wp_query/#status-parameters

How to view all posts of current day as default in admin

You can try this modification to your code snippet: function add_post_format_filter_to_posts( $query ) { global $post_type, $pagenow; // if we are currently on the edit screen of the post type listings if ( is_admin() && $pagenow == ‘edit.php’ && $post_type == ‘shop_order’ && ! filter_input( INPUT_GET, ‘filter_action’ ) // <– We add this check && … Read more

parse_tax_query causing Navigation Menu To Disappear

Query parsing happens on every query run on a page, not just the main query. Your parse_tax_query is modifying the query for menu items in your menu. Check is_main_query() to make sure you only change the main query: function no_child_terms($query) { if( !is_admin() && $query->is_main_query() ){ $query->tax_query->queries[0][‘include_children’] = 0; } } add_action(‘parse_tax_query’, ‘no_child_terms’);

Get next/prev image/attachment in time with date query

Based on the answer by @jan-becker I build this snippet. This works for me: /* * Get the next/prev image id inside c-tax: my_snapshot_position_ctax */ function my_return_relative_attachment_id( $this_post_ID, $prev = true ) { global $post; // overwrite global $post variable $post = get_post( $this_post_ID ); // filter sql query to work with attachment add_filter( ‘get_next_post_where’, … Read more