WP_Query and polylang issue

OK – I got it, the old posts already on the database do NOT have an english translation and that’s the problem with my loop. When I add a new post, I have the option to provide a translation which then appears in the english page. looking through the docs I found that I can … Read more

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