What format does the meta_query TIME type require?

Date and time format meta_query requires the same format you used when storing the data of the meta fields. Some times different formats can be compared directly, but most of the time they aren’t. A recommend format to use is MySQL format: date format: YYYY-MM-DD (for PHP date functions: Y-m-d) time format: HH:MM:SS (for PHP … Read more

WP_Query returning no results

you might also need to set the ‘post_type’ in $the_args, and possibly the ‘posts_per_page’; http://codex.wordpress.org/Class_Reference/WP_Query#Type_Parameters example: // WP_Query arguments $the_args = array ( ‘post__in’ => $results, ‘post_type’ => array( ‘any’ ), ‘posts_per_page’ => 10 );

Display posts with date wordpress default

you need to study about date query. Anyways following should work <?php $args = array( ‘posts_per_page’ => -1, ‘date_query’ => array( array( ‘after’ => ‘7 days ago’ ) ) ); $query = new WP_Query($args); while ( $query->have_posts() ) { $query->the_post(); // Page title the_title(); } // end while // Restore original Post Data wp_reset_postdata(); // … Read more

Meta query with JSON value

That’s not json. You can’t put a semi-colon inside a javaScript Object like that. That’s serialized-data. If you return that string & then call unserialize on it & then var_dump you can see what’s inside. Also, see fuxia♦’s Answer Here for more info. & to Maikal’s credit, you can use a meta_query in this situation, … Read more

ACF – Get lowest & highest value from field

Got it working in the end with the below code: <?php $args = array( ‘posts_per_page’=> -1, ‘post_type’ => ‘properties’, ‘meta_key’ => ‘development’, ‘meta_value’ => $development_id, ); $properties_query = new WP_Query( $args ); $prices = array(); if( $properties_query->have_posts() ): while( $properties_query->have_posts() ) : $properties_query->the_post(); $price = get_field(‘price’); if(isset($price) && !empty($price)){ $prices[] = $price; } endwhile; $max_price … Read more

WP_Query times out

What you are seeing isn’t “bad” exactly, you’ve just got a terrifically labor intensive query and WP_Query is not smart enough to optimize it– it doesn’t even try. Briefly, you’ve got a bunch of JOINs, you’ve got two LIKE conditions, which will read every row in the table of that post type, those likes are … Read more

WP_Query loop within WP_Query loop

It is still totally unclear what you actually want to do, but according to this: it works but the main loop generate duplicate posts I can tell you that it is expected output. Your “main” loop queries and displays all pages which has a parent page ID of 10. Lets say there are 10 pages … Read more

How to limit WP_Query to one result on the loop?

pre_get_posts alters all queries, back end and front end regardless. There are two very important checks that a large amount of people misses, that is the !is_admin() check which only targets the front end, and then the most important check, is_main_query() which will only alter the main query and not custom queries. You statement should … Read more