Calling generateblocks_do_content with a post ID argument
-
Hey team,
Any chance you already have or can modify your awesome
generateblocks_do_content
filter to take in apost ID
arg/param?We have a mutual customer (GenerateBlocks and Popup Maker customer) who needs to call your filter for multiple popups.
Here’s a quick proof of concept (POC) that calls your filter in a loop. Let me know if I’m missing something.
function my_generateblocks_do_content_loop ( $content, $post_id ) { if ( has_blocks( $post_id ) ) { $block_element = get_post( $post_id ); // Where 'popup' is the custom post type for Popup Maker popups. // The original text from the GenerateBlocks doc is 'your_post_type' // https://docs.generateblocks.com/article/adding-content-sources-for-dynamic-css-generation/ if ( ! $block_element || 'popup' !== $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; } add_filter( 'generateblocks_do_content', 'my_generateblocks_do_content_loop', 10, 2 ); // Popup IDs $numbers = array(113, 116); foreach ($numbers as $post_id) { // Get the content using the post ID $content = get_post_field('post_content', $post_id); // Apply the filter and pass the post ID $modified_content = apply_filters('my_generateblocks_do_content_loop', $content, $post_id ); } // foreach
Thanks!
The page I need help with: [log in to see the link]
Viewing 3 replies - 1 through 3 (of 3 total)
Viewing 3 replies - 1 through 3 (of 3 total)
- The topic ‘Calling generateblocks_do_content with a post ID argument’ is closed to new replies.