WordPress pre_get_posts with combined results of two queries (OR)

See WP_Query as reference for the post query filters. You can filter posts by their authors with the ‘author’ query var as you filter posts by their taxonomy with ‘tax_query’ query var. Then, conditionally set the ‘tax_query’ query var depending on the user’s company meta field. If it’s empty, set the ‘author’ query var instead. … Read more

wpdb print all post meta

This isn’t really a WordPress question as it’s just standard SQL, so it doesn’t really belong here, but I have some points to make about your use of $wpdb->prepare() so will answer the question. So, let’s look at your WHERE clause, isolated, with values substituted, and indented to reflect how it will be interpreted: WHERE … Read more

Slow queries on a huge database

As @milo said in the comments, the cat parameter (and similar parameters in other hierarchical taxonomies) will make the query look in subcategories as well. If you do not want that to happen use the category__in parameter. As for the general slowness, it is hard to guess, but it depends on your DB server performance … Read more