Querying by post category slug with core/query block markup

You should not modify the taxQuery value, or that it should always be in the form of {“<taxonomy>”:[<term IDs>],”<taxonomy>”:[<term IDs>],”<taxonomy>”:[<term IDs>],…}. But you can add custom arguments, so “categoryName”:”news” is good. And then you can use the query_loop_block_query_vars filter to add the category slug to the WP_Query arguments coming from the Query Loop block. Here’s … Read more

Why does $_GET return values but get_query_var does not?

Because they do different things and source their data from different places. $_GET is for URL parameters, values passed via HTTP GET. get_query_var is for fetching the query variables of the main post query aka the WP_Query object. Query variables and GET values are not the same thing. Query variables usually get their values either … Read more

Pre_get_comments and orderby comment_karma

I think you’re close with your 2nd snippet, but you should be using meta_value_num instead of meta_key_num. $query->set( ‘meta_key’, ‘comment_karma’ ); $query->set( ‘orderby’, ‘meta_value_num’ ); See the WP_Query orderby docs for more info.

Using Query Loop Block to list all posts under each category

Use WP_Query directly in your WP theme template files instead of a block editor. // Define custom taxonomy (category) terms $categories = get_terms(array( ‘taxonomy’ => ‘your_custom_taxonomy’, // Change ‘your_custom_taxonomy’ to the name of your taxonomy ‘hide_empty’ => false, )); // Loop through each category foreach ($categories as $category) { echo ‘<h2>’ . $category->name . ‘</h2>’; … Read more