Exlude current post

Hello to the US,

switched from WPSP to GenerateBlocks. In WPSP there was a general option to “exclude current”. Is the selection also available in GenerateBlocks or is this only possible with the Pro version?

Greetings from Munich

Uwe

Hi @gpblock,

It’s a feature planned for the Pro version. You can also use a filter to do as such.

Add my-class-name to the Post Template Block as such: Edit Page “Home” ‹ fazarcon...

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['post__not_in'] = [get_the_ID()];
    }

    return $query_args;
}, 10, 2 );

Adding PHP reference: Adding PHP - Documentation

Hope this helps!

Hello, fernandoazarcon2,

it works perfect, thanks so much!

Greetings from Munich

You’re welcome @gpblock! Greetings!

This feature is now available in GenerateBlocks Pro 1.3.0 (currently in alpha).

Works great. The only thing I would suggest is to integrate it with multilingual support.
What I mean is, if a page, post or taxonomy is chosen in one language, it shall work in all languages. Actually it is necessary to select the parameters manually for each language. Thus, it is not possible to automate the placement of the queries.