Speed optimization of $wpdb->get_results

Your query is incorrect in the first place because you’re not doing the join correctly. What you’re actually selecting with that query is just all the postmeta’s autor fields, without regards to whether the post is published or not. Here’s the corrected query. SELECT meta_value AS autor FROM wp_posts JOIN wp_postmeta ON (wp_postmeta.post_id = wp_posts.ID) … Read more

Calling Specific Pages with wp query Part II

Two issues here The default page post type is page, not pages Your meta_query is wrong, it should be an array of an array, not just an array Your arguments should be $args = array( ‘post_type’ => ‘page’, ‘order’ => ‘ASC’, ‘posts_per_page’ => 50, ‘meta_query’ => array( array( ‘key’ => ‘field_5505a81b83234’, // field key generated … Read more

loop query exclude meta_key with meta_value

Do NOT use query_posts() – it is bad, very bad to be exact. For more information read: When should you use WP_Query vs query_posts() vs get_posts()? When to use WP_query(), query_posts() and pre_get_posts Use WP_Query instead. Example with meta_key, meta_value and meta_compare parameters in use: $args = array( ‘meta_key’ => ‘clpr_excoupon’, ‘meta_value’ => ‘0’, ‘meta_compare’ … Read more

WP_User_Query with meta_query array relation ‘OR’

From the Codex: Multiple custom user fields handling $args = array( ‘meta_query’ => array( ‘relation’ => ‘OR’, 0 => array( ‘key’ => ‘country’, ‘value’ => ‘Israel’, ‘compare’ => ‘=’ ), 1 => array( ‘key’ => ‘age’, ‘value’ => array( 20, 30 ), ‘type’ => ‘numeric’, ‘compare’ => ‘BETWEEN’ ) ) ); Try adding the 0 … Read more