WordPress query: merge meta key (number) values and sort

I think this is the syntax you are after: $args = [ ‘posts_per_page’ => 5, ‘post_type’ => ‘post’, ‘meta_query’ => [ ‘relation’ => ‘OR’, ‘rating_au_clause’ => [ ‘key’ => ‘rating_au’, ‘compare’ => ‘EXISTS’ ], ‘rating_overall_clause’ => [ ‘key’ => ‘rating_overall’, ‘compare’ => ‘EXISTS’ ] ], ‘orderby’ => [ ‘rating_au_clause’ => ‘ASC’, ‘rating_overall_clause’ => ‘DESC’, ], … Read more

Get posts that match defined arrays of tags

This should be achievable with a taxonomy query, like this: $query = new WP_Query( [ ‘tax_query’ => [ ‘relation’ => ‘AND’, [ ‘taxonomy’ => ‘post_tag’, ‘terms’ => $platforms, ‘compare’ => ‘IN’, ], [ ‘taxonomy’ => ‘post_tag’, ‘terms’ => $hashtags, ‘compare’ => ‘IN’, ], ], ] ); You just need to substitute the $platforms and $hashtags … Read more

Delete oldest wordpress post (SQL query)

I figured it out! Pretty simple actually.. You can replace post_date_gmt with ID depending on your needs. post_author != 1 will prevent the admin’s post from being deleted, so the menu links and pages will stay intact 🙂 function deleteOldestPost(){ global $wpdb; $prefix = $wpdb->prefix; $wpdb->query(“DELETE FROM “.$prefix.”posts where post_author != 1 order by post_date_gmt … Read more

WP_Query filter by custom meta

You can do a meta query using OR relation. After that you use get_users() function to get all the users you selected in the query. Then output their nicename in a list with using foreach. $your_url=”https://www.yoururl.com”; $your_description = ‘your description’; $args = array( ‘meta_query’ => array( ‘relation’ => ‘OR’, array( ‘key’ => ‘user_url’, ‘value’ => … Read more