Skip Navigation

[Eskaliert auf 2. Stufe] GenerateBlocks CSS not working on Toolset WordPress Archives template

This support ticket is created vor 2 Jahre, 4 Monate. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

No supporters are available to work today on Toolset forum. Feel free to create tickets and we will handle it as soon as we are online. Thank you for your understanding.

Sun Mon Tue Wed Thu Fri Sat
- 7:00 – 14:00 7:00 – 14:00 7:00 – 14:00 7:00 – 14:00 7:00 – 14:00 -
- 15:00 – 16:00 15:00 – 16:00 15:00 – 16:00 15:00 – 16:00 15:00 – 16:00 -

Supporter timezone: Europe/London (GMT+01:00)

This topic contains 7 Antworten, has 2 Stimmen.

Last updated by Alok Sharma vor 2 Jahre, 3 Monate.

Assisted by: Nigel.

Author
Artikel
#2248703

Hi,

This is with reference to the previously reported issues where in the GenerateBlocks CSS does not work on the front-end when using Toolset.

The workaround mentioned over here https://toolset.com/errata/generateblocks-styles-lost-on-front-end-when-using-content-templates/ only works for Content Templates, not for WordPress Archives.

GenerateBlocks works perfectly fine when designing the WordPress Archives, but on the front-end, the CSS is not working.

I don't know when Toolset & GenerateBlocks are going to work this out but for the time being, is there any workaround to this?

Thanks.

#2248917

Nigel
Supporter

Languages: Englisch (English ) Spanisch (Español )

Timezone: Europe/London (GMT+01:00)

Let me look into this and see if I can find a variation of the workaround to cover archives, too.

I'll get back to you...

#2249791

Nigel
Supporter

Languages: Englisch (English ) Spanisch (Español )

Timezone: Europe/London (GMT+01:00)

I looked into this and it isn't currently possible to provide such a workaround for custom archives, because GeneratePress doesn't itself output content with blocks on archive pages, and so it isn't internally geared up for adding its block styles to archive pages, and hence there is no way to simply intervene and ensure that the styles are enqueued.

Adding such support is likely to require collaboration with the plugin developer, so I've added details to an internal ticket and am escalating this thread to it so that if we do get some news in the future I can update you.

#2265197

Hi,

I had a discussion with Tom Usborne, the developer of GeneratePress, and he said that - "he hasn't heard much from Toolset at all when it comes to integration".

Besides, he also said that - "Toolset would need to apply this kind of fix to make GB compatible with their plugin: hidden link

It's quite an easy fix - not sure why it hasn't been implemented."

#2265699

Nigel
Supporter

Languages: Englisch (English ) Spanisch (Español )

Timezone: Europe/London (GMT+01:00)

I went back and took another look at the possibility of getting it to work on custom archive pages, and I have it working on my local test site.

Let me share the code with you, and if you confirm it works I'll update the internal ticket and the erratum so other users can benefit until the developers include a formal solution.

add_filter('generateblocks_do_content', function ($content) {

    // Array of post types slugs which use Content Templates or custom WPAs
    $post_types = array( 'thing' );

    if ( is_singular( $post_types ) )
    {
        global $post;
    
        // is the post being displayed with a Content Template?
        $template_id = apply_filters( 'wpv_content_template_for_post', 0, $post );
    
        if (isset($template_id) && !empty($template_id)) 
        {
            if (has_blocks($template_id)) 
            {
                $template = get_post($template_id);    
                // Append the template "content" to the post content, for scanning by GP
                $content .= $template->post_content;
            }
        }
    } elseif ( is_post_type_archive( $post_types ) ) 
    {
        // is there a custom WPA for this post type?
        $post_type = get_query_var( 'post_type' );
        $wpa_id = wpv_has_wordpress_archive( 'post', $post_type );
        if (isset($wpa_id) && !empty($wpa_id)) 
        {
            $wpa_helper = get_posts
            ( array
                ( 
                    'post_type' => 'wpa-helper',
                    'post_parent' => $wpa_id,
                    'post_status' => 'publish'
                )
            );
            if (isset($wpa_helper) && !empty($wpa_helper))
            {
                if (has_blocks($wpa_helper[0])) 
                {
                    $content .= $wpa_helper[0]->post_content;
                }
            }
        }
    }
    return $content;
});

You only need to specify the slugs of the custom post types you want this to work with (for content templates and custom post archives) at the top.

Let me know how you get on.

#2266145

Hi Nigel,

Awesome, it worked like a charm.

I had a small issue with adding CPT slugs but figured it out quickly. Just in case, beginners or newcomers shouldn't face the same problem, I am putting it down here:

add_filter('generateblocks_do_content', function ($content) {
 
    // Array of post types slugs which use Content Templates or custom WPAs
    $post_types = array( 'slug-1', 'slug-2', 'slug-3' );
 
    if ( is_singular( $post_types ) )
    {
        global $post;
     
        // is the post being displayed with a Content Template?
        $template_id = apply_filters( 'wpv_content_template_for_post', 0, $post );
     
        if (isset($template_id) && !empty($template_id)) 
        {
            if (has_blocks($template_id)) 
            {
                $template = get_post($template_id);    
                // Append the template "content" to the post content, for scanning by GP
                $content .= $template->post_content;
            }
        }
    } elseif ( is_post_type_archive( $post_types ) ) 
    {
        // is there a custom WPA for this post type?
        $post_type = get_query_var( 'post_type' );
        $wpa_id = wpv_has_wordpress_archive( 'post', $post_type );
        if (isset($wpa_id) && !empty($wpa_id)) 
        {
            $wpa_helper = get_posts
            ( array
                ( 
                    'post_type' => 'wpa-helper',
                    'post_parent' => $wpa_id,
                    'post_status' => 'publish'
                )
            );
            if (isset($wpa_helper) && !empty($wpa_helper))
            {
                if (has_blocks($wpa_helper[0])) 
                {
                    $content .= $wpa_helper[0]->post_content;
                }
            }
        }
    }
    return $content;
});
#2266299

Nigel
Supporter

Languages: Englisch (English ) Spanisch (Español )

Timezone: Europe/London (GMT+01:00)

Thanks for confirming. I've updated the internal ticket as well as the erratum.

I leave this ticket escalated, and update if there is a permanent fix so that you can remove the workaround.

#2266301

Perfect 🙂