Site logo

Archived topic

Block element: incorrect display of a post grid

5 replies · Started by Marc on June 6, 2022

Viewing posts 1–6 of 6

Hello, on a website I have posts with certain keywords. Now I want to show a post grid on all posts below the main content (Hook: generate_after_content), which displays teasers of posts that also have the respective keyword.

For the grid display of the teasers I use the plugin Spectra (fka "Ultimate Addons for Gutenberg") from Brainstorm Force.

If I only include this grid directly below the post content in the post, everything works perfectly (https://prnt.sc/FnkZ73XtxvEu).

Now I tried to create a block under Elements that includes this grid. Then I set the rule that this block will be output on all posts that also have the same keyword. Technically this works fine, but unfortunately the grid is output unformatted or incorrectly formatted.

If I include the grid (as a test) both in the post and as an element block below the content, then the teasers are output in columns, but without further formatting.

If I include the grid in a post only via the element block, then the teasers are output completely unformatted (https://prnt.sc/cLzpxAu1EneW).

How do I make it so that I include the grid only once as a block element and that the teasers are displayed properly formatted?

Thank you very much for a tip!

Marc

Hi there,

i believe UAG parses the post content to see whether its blocks are present. But it won't know of the Elements post type so won't render its CSS. Another user had a similar issue - see reply with the filter required to tell the plugin what other post types to look for:

https://generatepress.com/forums/topic/issue-with-adding-ultimate-addons-for-gutenberg/#post-2020164

Alternatively we're real close to releasing GB 1.5 which has its own Query Loop block, you may want to check that out:

https://generateblocks.com/generateblocks-1-5-dynamic-data-query-loops-image-blocks/

Hi David, thanks a lot for your tips. I have installed the filter, unfortunately the formatting still doesn't work....

I have included this code in the functions.php of my child theme:


add_action( 'wp_enqueue_scripts', 'enqueue_scripts_by_post_id' );

function enqueue_scripts_by_post_id() {

    if ( 'post' == get_post_type() ) {
        $post_id = get_the_id();
        // Create Instance. Pass the Post ID.
        $post_assets_instance = new UAGB_Post_Assets( $post_id );

        // Enqueue the Assets.
        $post_assets_instance->enqueue_scripts();

    }
    
}

This has not changed the representation of the grid. Example: http://neu.wasserkuppe.net/wandern/ -> the Grid should be shown below the "Weitere Angebote" heading.

Do you have any idea what I did wrong?

Thanks again a lot and sunny greetings,

Marc

Yeah i am not sure how that function is meant to work.
Could you check with UAGB Support ?

All right no problem, I'll do that!

Thank you and have a nice day, Marc

Let us know how you get on, or if they need any info from us.

This archived topic is closed to new replies.