Query for current post

You shouldn’t be writing any query. WordPress does this for you. You single-{post type}.php template should only contain the standard loop: <?php if ( have_posts() ) : while ( have_posts() ) : the_post(); // Display post content endwhile; endif; ?>

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

Get posts for each user

According to the WP_Query::parse_args docs (which is what parses the $args you’re passing to get_posts()), the $author parameter needs to be an int or a string (a comma-separated list of IDs). But you’re also going to need this set up in groups, per student, so here’s what I’d recommend: use an array to store each … Read more

pre_user_query vs pre_get_posts

The pre_get_posts function is a simple query modifier for general “post” queries. If you’re looking to modify the SQL directly for these query I suggest using the post_clauses hook. This hook passes an array of SQL clauses such as: $sql[‘where’] and sql[‘join’] Here you can inject your own custom SQL into the specific clauses. That … Read more