Query loop support for custom taxonomies

The recent addon to the post query block for categories and tags is great - But the option for custom taxonomies would allow for dynamic custom post type loops for some really awesome and dynamic gutenburg block content. The loop block could maybe just have a single field that supports a string of taxonomies (eg faq:web,host;type:blue,large;) and these can be filled dynamically with other block attributes using the @ feature.

1 Like

I can see how building a robust wp_query interface would be…a challenge. Maybe, rather than adding a bunch of options for edge cases, @matjaz can offer us an interface to directly edit the $args for the query? That would let us do all sorts of complex queries while still letting pinegrow handle the display options and loop structure.

<?php
 
$args = array(
    'category_name' => 'news',
    'posts_per_page' => 3
);
 
$my_query = new WP_Query( $args );
 
if ( $my_query->have_posts() ) {
    while ( $my_query->have_posts() ) {
        $my_query->the_post();
        // Post data goes here.
    }
}
 
// Reset the `$post` data to the current post in main query.
wp_reset_postdata();
 
?>

@adamslowe this is already possible, as described here:

3 Likes

I should never have doubted you! I guess I wasn’t seeing it because I was using the Show Posts Smart Action, not the general “The Loop” action.

I’m going to need to make a video of this one.

2 Likes

@adamslowe a video on this would be very helpful! Also, do you think this option is important enough to include it in the Show Posts action?

2 Likes

If it isn’t too much trouble, I can see how it would be useful on the show posts action as a bridge between “Show Posts” and the more complex/manual “The Loop” action.

There also seems to be a misconception that the Smart Actions are the right way to do everything now and that the other actions are somehow “legacy.” I sort of understand how that is since the Smart Actions are so easy to use and most of the current tutorials focus on them. Maybe it’s just because normal WordPress users are used to having abstracted controls for WP Functions (similar to Smart Actions), and they just aren’t used to dealing directly with the functions. I don’t have any solutions to this dilemma, only an observation.