How to clear the cache?

Have you looked at WP_Object_Cache? If you suspect there is unwanted caching happening in the code that generates the admin panel then you might be able to use functions from the WP_Object_Cache to clear it. WP_Object_Cache is WordPress’ class for caching data which may be computationally expensive to regenerate, such as the result of complex … Read more

Secondary Sort (fallback) for WP_Query

It’s a quite simple revision to your current code. You can add multiple “orderby” values separated by a space. ‘orderby’ => ‘meta_value_num title’, This should keep the priority of sorting by your meta value, with a secondary sort of title.

Use WP_Query with have_posts()?

global $wp_query; $original_query = $wp_query; $wp_query = null; $wp_query = new WP_Query( $args ); if ( have_posts() ) : while ( have_posts() ) : the_post(); the_title(); the_excerpt(); endwhile; else: echo ‘no posts found’; endif; $wp_query = null; $wp_query = $original_query; wp_reset_postdata(); http://codex.wordpress.org/Function_Reference/wp_reset_postdata

WP_query to get the first two latest posts, then another loop to get the next three

Run one wp_query for post_per_page = 2 and get the IDs of these 2 posts in an array to be excluded in the next 3 posts needed <?php // The Query $next_args = array( ‘post_type’ => ‘<your_post_type>’, ‘post_status’ => ‘publish’, ‘posts_per_page’=>2, ‘order’=>’DESC’, ‘orderby’=>’ID’, ); $the_query = new WP_Query( $args ); // The Loop if ( … Read more

WP_Query: query posts by ids from array?

You have to use post__in (double underscore) argument, instead of post_in: echo print_r($rel); // Array ( [0] => 63 [1] => 87 ) $args = array( ‘post_type’ => array( ‘post’ ), ‘orderby’ => ‘ASC’, ‘post__in’ => $rel ); $loop = new WP_Query( $args ); If you are unsure why an argument is not working, copy … Read more

tech