If you have multiple dynamic blocks with a post loop on a page, how do you avoid duplicates from inside the render_callback function?

In PHP I recall these ways Static variables Class properties Databases, Files, Memory (might be flushed though) to preserve a state, in a hook’s callback, that is called multiple times in WordPress and in the order I would consider using myself but it depends on the context (eg WP transients, that store data that expires, … Read more

Gutenberg: Prevent links from being clickable in the block. Error: “Cannot destructure property ‘frameElement’ of ‘r’ as it is null.”

It seems that this helped: $is_backend = defined(‘REST_REQUEST’) && true === REST_REQUEST && ‘edit’ === filter_input(INPUT_GET, ‘context’, FILTER_SANITIZE_STRING); if ( $is_backend == true) { $url = “#void”; } else { $url = get_permalink( $post_id ); }; $link = ‘<a ‘ . $fontsizeattr . ‘ href=”‘ . $url . ‘” target=”_self”>’ . $game_title . ‘</a>’; return … Read more

Can I use WP blocks in a template?

2 methods do_blocks, takes block content as a string, parses them, renders each block, then returns the final rendered content. This is the same content in post_content, aka the HTML comment and the HTML tags inside it e.g. something similar to this: echo do_blocks( ‘<!– wp:paragraph –><p>Hello world.</p><!– /wp:paragraph –>’); Use a block template part … Read more