Query posts filter not working
Query posts filter not working
Query posts filter not working
Get posts from similar time as current post
Is their anyway we can do the filtering (i.e comparing 3 values) in wp_query itself? What you are asking is tricky in pure SQL, though it can be done. WP_Query cannot handle the logic natively, though. You would have to create one or more filters. Doing this with the data structure you have right now … Read more
Query custom post type by date field only working when two posts match the query
Post OrderBy slow performance
Custom WP_Query with SQL directives for getting posts by authors and terms
How to add archives (with pagination) to page template?
Just build the static part of the args array, then add the conditional variables, then pass the args array to WP_Query(): // Static args $custom_query_args = array( /* static args here */ ); // Conditional arg if ( 1 == $promo ) { $custom_query_args[‘meta_query’] = array( /* meta query array */ ); } // Instantiate … Read more
Sort posts in dashboard using custom field; also include posts where field isn’t set
I don’t understand why can’t you use the post_date of the custom post type which includes date and time together? $arg = array( ‘post_type’ => ‘custom_post_type’, ‘orderby’ => ‘post_date’, ‘order’ => ‘DESC’) $result = get_posts($args);