• Resolved rom1our

    (@rom1our)


    Hello,
    I tried to insert a grid with 2 container in the Advanced Ads editor. In each container is a WP show post list and a Generateblocks button.
    This is, how it shall look like but somehow the CSS formatting is missing, when I insert the code into Advanced Ads. The same thing happended when I tried to insert a code into popup maker.

    Is there a way to solve this?

    The page I need help with: [log in to see the link]

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

    (@edge22)

    Hi there,

    GenerateBlocks styling is built to work within your content area.

    When it comes to third-party locations, integration needs to be specifically added: https://docs.generateblocks.com/article/adding-content-sources-for-dynamic-css-generation/

    It’s something the support team/developer of that plugin should be able to help with ??

    Thread Starter rom1our

    (@rom1our)

    Hi Tom,
    great.

    Two questions about the post_id. In the sample is
    $post_id = 123; // A post ID to check the content of. Can be dynamically set.

    1. Can I create a list like 123;124;125;…
    2. Is it possible to include all posts of a post type (like ‘advanced_ads’).

    Thank you

    Plugin Author Tom

    (@edge22)

    Absolutely, you can do this:

    add_filter( 'generateblocks_do_content', function( $content ) {
        $args = array(
            'post_type' => 'advanced_ads',
            // Other args if you need them.
        );
    
        $posts = get_posts( $args );
    
        foreach ( (array) $posts as $post ) {
            if ( isset( $post->post_content ) ) {
                $content .= $post->post_content;
            }
        }
    
        return $content;
    } );

    You may want to add some conditions in there so this only happens on pages where it’s needed, as this will tell GenerateBlocks to scan the content of all posts in that post type on every page and include the CSS. That may not be necessary depending on your setup.

    Thread Starter rom1our

    (@rom1our)

    I’m made a test for the post type “popup”.
    It works properly on the category pages like https://test.tourist-in-rom.com/en/rome-practical-tips/, but not on the posts like https://test.tourist-in-rom.com/en/top-restaurants-in-rome/
    In both cases, the same popup is used.

    Plugin Author Tom

    (@edge22)

    How can I initiate the popup?

    Can you try regenerating your CSS in “GenerateBlocks > Settings”?

    Let me know ??

    Thread Starter rom1our

    (@rom1our)

    OK, now it works.

    About my 1st question. I need to add the post ID’s 42332; 42333; 42334; for the post type advanced_ads

    I tried

    add_filter( 'generateblocks_do_content', function( $content ) {
        $post_id = 42332;42333;42334; // A post ID to check the content of. Can be dynamically set.
    
        if ( has_blocks( $post_id ) ) {
            $block_element = get_post( $post_id );
    
            if ( ! $block_element || 'advanced_ads' !== $block_element->post_type ) {
                return $content;
            }
    
            if ( 'publish' !== $block_element->post_status || ! empty( $block_element->post_password ) ) {
                return $content;
            }
    
            $content .= $block_element->post_content;
        }
    
        return $content;
    } );

    but this takes only the first ID. How can I do this?

    Plugin Author Tom

    (@edge22)

    You need to loop through each ID:

    add_filter( 'generateblocks_do_content', function( $content ) {
        $post_ids = array( 42332, 42333, 42334 ); // A post ID to check the content of. Can be dynamically set.
    
        foreach ( $post_ids as $post_id ) {
            if ( has_blocks( $post_id ) ) {
                $block_element = get_post( $post_id );
    
                if ( ! $block_element || 'advanced_ads' !== $block_element->post_type ) {
                    return $content;
                }
    
                if ( 'publish' !== $block_element->post_status || ! empty( $block_element->post_password ) ) {
                    return $content;
                }
    
                $content .= $block_element->post_content;
            }
        }
    
        return $content;
    } );

    Hope this helps!

    Thread Starter rom1our

    (@rom1our)

    Perfect, thank you ??

    Plugin Author Tom

    (@edge22)

    You’re welcome ??

Viewing 9 replies - 1 through 9 (of 9 total)
  • The topic ‘Use with Advanced Ads (and popup maker)’ is closed to new replies.