Filter RSS feed for custom post type to events for next 7 days only
Filter RSS feed for custom post type to events for next 7 days only
Filter RSS feed for custom post type to events for next 7 days only
just changed the query a little $meta_query_args=array( ‘relation’ => ‘AND’, array( ‘key’ => ‘event-start-date’, ‘value’ => $date_today, ‘compare’ => ‘<‘, ) ); $loop = new WP_Query( array( ‘post_type’ => ‘events’, ‘posts_per_page’ => 5 , ‘meta_key’ => ‘event-start-date’, ‘orderby’ => ‘event-start-date’, ‘order’=>’desc’, ‘meta_query’ => $meta_query_args ) ); if($loop->have_posts()): while ( $loop->have_posts() ) : $loop->the_post(); but can … Read more
You need to use the type parameter for custom field. Try this once <?php $currentshowid = get_the_ID(); $today = date(‘Y-m-d’); $args = array( ‘meta_key’ => ‘show_id’, ‘meta_value’ => $currentshowid, ‘orderby’ => ‘meta_value_num’, ‘order’ => ASC, ‘meta_query’ =>array( ‘relation’ => ‘AND’, array( ‘key’ => ‘date_end’, ‘value’ => $today, ‘compare’ => ‘>=’, ‘type’ => ‘date’ ), ), … Read more
This piece of code should solve your problem: function filter_where($where=””) { $where .= ” AND post_date < ‘” . date(‘Y-m-d’) . “‘”; return $where; } add_filter(‘posts_where’, ‘filter_where’); $query = new WP_Query(array(‘posts_per_page’ => 3)); remove_filter(‘posts_where’, ‘filter_where’);
The problem was that the nc_hidden met property did not exist if it was not checked so there was essentially no value to query against. I swapped nc_hidden from a checkbox to a select and updated my query as required. The working query is now as follows: $query_args = array( ‘posts_per_page’ => ‘1’, ‘orderby’ => … Read more
How to compare date in post meta value
Orderby Meta Value and Query from Meta Query
Some thoughts on how I would approach this. I can update later with some code if necessary when I have the time. I would handle the first page with two additional queries, so three loops on page one. Hook pre_get_posts and do two meta queries for the three posts that will appear in the first … Read more
How to show specific meta keys of all posts in admin panel?
You can make use of REGEXP operator in META_COMPARE. For example: $meta_array[] = array( ‘key’ => ‘_item_allowed_companies’, ‘value’ => $allowed_company, ‘compare’ => ‘REGEXP’ ); $args = array( ‘post_type’ => ‘item’, ‘post_status’ => ‘publish’, ‘posts_per_page’ => $posts_per_page, ‘paged’ => $paged, ‘meta_query’ => $meta_array ); References: WP_Query Custom Field parameters Trac ticket #18736