• Resolved jlop77

    (@jlop77)


    Hi,

    I use the Astra theme. This allows me to add content using Hook. I usually add Kadence blocks to the footer, through this method.

    GenerateBlock is very configurable, it seems excellent to me; But disartunately when I create a layout with GB, it is not shown by Hook.

    I have also made the Pruba with the plugin “Ultimate Gutenberg” and it works.

    Is there a solution, for GB, show properly via Hook?

Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Author Tom

    (@edge22)

    Hi there,

    Yes, you will need to ask Astra how you can implement the following method with their hooks: https://docs.generateblocks.com/article/adding-content-sources-for-dynamic-css-generation/

    They should be able to help quite easily ??

    Thanks!

    Thread Starter jlop77

    (@jlop77)

    Excellent.

    I’m not an expert and I could do it very easily.

    My favorite topics are Astra and Generatepress, use them with all my clients. Waiting with longing the new version of Generatepress Premium.

    Thanks.

    Thread Starter jlop77

    (@jlop77)

    One last question, how do I do to group several $ post_id? I would like to use this method with several Hook that I want to implement.

    I did the test separating them with commas and it did not work:

    add_filter( ‘generateblocks_do_content’, function( $content ) {
    $post_id = 1549, 1552;

    Sorry, I imagine it’s easy, but I do not have knowledge ??

    Plugin Author Tom

    (@edge22)

    Ideally you would be able to dynamically get all post IDs that are “hooks” instead of manually defining them.

    Then you could do this:

    add_filter( 'generateblocks_do_content', function( $content ) {
        $post_ids = array( 123, 456, 789 );
    
        foreach ( $post_ids as $post_id ) {
            if ( has_blocks( $post_id ) ) {
                $block_element = get_post( $post_id );
    
                if ( ! $block_element || 'your_post_type' !== $block_element->post_type ) {
                    continue;
                }
    
                if ( 'publish' !== $block_element->post_status || ! empty( $block_element->post_password ) ) {
                    continue;
                }
    
                $content .= $block_element->post_content;
            }
        }
    
        return $content;
    } );

    Be sure to adjust your_post_type to the slug of the correct post type.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘gb in footer (by hook)?’ is closed to new replies.