WP_User_Query orderby meta_val_num
This is untested, but I believe if you set type in your meta query to numeric, that will cast the values as numbers so orderby meta_value should work correctly.
This is untested, but I believe if you set type in your meta query to numeric, that will cast the values as numbers so orderby meta_value should work correctly.
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
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>
Your problem is your naming convention. Look at the Template Hierarchy. The archive- prefix is reserved for date and custom post type archive pages. You are using this as prefix to a page template This is not only confusing to humans, but to WordPress as well. For page templates you should be using the page- … Read more
You cannot mix array syntax and string syntax in the same argument. If you start with array syntax, you should stick with that, the same applies if you start with string syntax, then you should stick with string syntax. Because you are using post__not_in which is an array, you should stick with array syntax <?php … Read more
It is already solved here. https://stackoverflow.com/questions/16889207/how-to-order-wordpress-posts-by-a-custom-field-date Just make sure you use ‘meta_value_num’ for ‘orderby’ and convert your date values from custom meta’s to ‘yyyymmdd’.
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
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
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’);
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