Query Loop Show current users posts

In the Query Loop ( Query Parameters ) you can add a filter for Author. This appears to be just a fixed Author Name, selected from a dropdown. Is there any way to make this dynamic so that you could add the Current User name. This would let me display the current users posts.

Not sure if this is possible or planned or maybe should be a feature request?


Hi Alanj,

You may use generateblocks_query_loop_args filter.

Try adding my-class-name to the class of the Grid Block within the Query Loop Block: Edit Page “Test Page for im...

Then add this PHP snippet:

add_filter( 'generateblocks_query_loop_args', function( $query_args, $attributes ) {
    if ( ! empty( $attributes['className'] ) && strpos( $attributes['className'], 'my-class-name' ) !== false ) {
		$query_args["author__in"] = array( get_current_user_id() );

    return $query_args;
}, 10, 2 );

Adding PHP reference: Adding PHP - Documentation

Hope this helps!

Many thanks, that helps a lot.

Of course it would be nice to have more dynamic support within the Blocks themselves … I live in hope!


You’re welcome Alanj!

This is something being considered probably for the GB Pro version by our developers but not sure yet.


Great news. Dynamic everywhere please!
( I do have GP/GB Pros already )