$args = array( 'post_type' => 'post', 'post_status' => 'publish', 'meta_query' => array( 'relation' => 'AND', 'post_type' => array( 'key' => 'file_post_type', 'value' => 'software', ), 'post_views' => array( 'key' => 'post_views_count', ), ), 'orderby' => array( 'post_views' => 'DESC', ), 'date_query' => array( array( 'after' => '1 month ago' ) ), 'numberposts' => $number, 'cache_results' => false, 'fields' => 'ids' ); $mview = get_posts($args); … [Read more...] about Get post by two meta key but order by one of them
$args = array( 'orderby' => 'display_name', 'meta_key' => 'course', 'fields' => 'all', 'search' => $search, 'meta_query' => array( array( 'key' => 'clinic', 'value' => $search, 'compare' => 'LIKE' ) ) ); Also, not sure if i have this set up correctly, but i also need the query to check if the meta key "course" exists, regardless of its value (but this is secondary, and can be removed if it might cause problems, im mostly concerned with it searching the clinic meta key) … [Read more...] about Wp_user_query search by meta_key not returning any results
... $post_title = $row->post_title; $id = $row->ID; $post_count = $wpdb->get_var(" SELECT COUNT(DISTINCT $wpdb->postmeta.meta_key) FROM $wpdb->posts LEFT JOIN $wpdb->postmeta WHERE $wpdb->posts.post_type = 'things' AND $wpdb->postmeta.meta_key = 'dates' AND post_id = $id "); echo $post_title . ' (' . $post_count . ')' . "\n"; } Similarly, I'd like to count the number of meta keys in total related to a custom post, any help on either of these would be greatly appreciated! … [Read more...] about Counting number of identical meta keys
Recent updates to this plugin broke my client's site, where the posts that had external featured images would not display them. And examining the plugin code itself (poor documentation, direct SQL queries on the database) lends me to believe he doesn't quite know what he's doing. … [Read more...] about Is it unethical to remove another plugin’s meta keys?
I am able to sort my posts by a custom field ('tour_length_days'). However if this field does not exist on an existing post then it will return no results. I was hoping there was a way to conditionally check to see if that meta key has a value before adjusting the query? … [Read more...] about Pre get posts sort by meta key returns no results if meta key does not exist