Site logo

[Support request] Preview for upcoming/scheduled posts using Query Loop Block?

Home Forums Support [Support request] Preview for upcoming/scheduled posts using Query Loop Block?

Home Forums Support Preview for upcoming/scheduled posts using Query Loop Block?

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #2412229
    Sascha

    Hi

    please, allow me to handle this request here, since I use both GPP & GBP and would like to keep all my support tickets here.

    On this site the currently published posts are displayed via Query Loop Block.

    Now we’d like to add another section to display only the titles of upcoming (scheduled) posts and I wonder if this is possible at all?

    Thank you in advance and kind regards,
    Sascha

    #2412449
    David
    Staff
    Customer Support

    Hi there,

    you could try:

    1. Add this PHP Snippet:

    
    add_filter( 'generateblocks_query_loop_args', function( $query_args, $attributes ) {
    	// Check your logic to apply the filtering only to specific loop
    	if (
    		! empty( $attributes['className'] ) &&
    		strpos( $attributes['className'], 'future-posts' ) !== false &&
    		is_home() &&
    		! is_admin()
    	) {
    		// Merge the current $query_args which contains arguments defined in the editor with your ordering arguments
    		return array_merge( $query_args, array(
    			'post_status' => 'future',
    		) );
        }
    
        return $query_args;
    }, 10, 2 );

    2. Select the Query Loops Grid Block and give it an Advanced > Additional CSS class of: future-posts

    That should add the 'post_status' => 'future' parameter to the query,

Viewing 2 posts - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.