Using patterns within edit.js (editor) – dynamic custom block

[ad_1]

I have created a custom block that lets the user build a query and pick a pattern for display purposes. I am able to render the pattern in the frontend using php but not in the editor. Is there a way to use a pattern in edit.js in a dynamic custom block?

edit.js:

{posts &&
posts.map((post) => {
[USE PATTERN HERE ??] );
})}

I am able to accomplish this in render.php

while ($query->have_posts()) : $query->the_post();
$posts .= do_blocks( ‘<!– wp:pattern {“slug”:”‘ . $pattern . ‘”} /–>’ );
endwhile;

Thanks

[ad_2]
1 Comment
  1. In the edit.js you need to use JavaScript – a variant of React.js to be more exact. The extension of the file (.js) implies that you can only use the JavaScript.

 

This site will teach you how to build a WordPress website for beginners. We will cover everything from installing WordPress to adding pages, posts, and images to your site. You will learn how to customize your site with themes and plugins, as well as how to market your site online.

Buy WordPress Transfer