How to make OR condition in WP_Query

WP_Query does not handle this sort of query: use two instances of WP_Query, and then combine the results. Untested code: $posts = new WP_Query( array( ‘post_type’ => ‘post’, ) ); $post_ids = array_column( $posts->posts, ‘ID’ ); $author = new WP_Query( array( ‘post_type’ => ‘any’, ‘author’ => 123, ‘post__not_in’ => $post_ids, // prevent duplicates ) ); … Read more

This SQL request call all time and overload my server : SELECT meta_value FROM wp_sitemeta WHERE meta_key = ‘wp_installer_network’ AND site_id = 1

What is it It’s most likely a part of the WPML. This is based on a quick copy paste of wp_installer_network into the github search box. There’s also a small chance this is the Types plugin, but you mentioned you had a multilingual plugin installed. No references to wp_installer_network are found in WordPress itself. and … Read more

SQL query to retrieve the number of WordPress posts with all given categories

There is a working example that only counts posts that are associated with both categories. This is tested with 3 posts, not 5000. function count_posts_with_categories($cat_ids) { global $wpdb; $cat_count = 0; // A subquery to get all posts that are assigned to each category $subquery = “SELECT object_id FROM $wpdb->term_relationships WHERE term_taxonomy_id IN (” . … Read more