How to create own shortcode widget in WordPress
Developers can create own widgets for inserting its by shortcodes in block editor. This allows you to quickly add the necessary widget to any page in the future without involving a developer.
For create a new shortcode widget use next code in your theme functions.php or plugin file:
add_shortcode('mywidget', function($args){
$args = shortcode_atts(
[
'per_page' => '10', // Some param for customize widget from block editor
],
$args,
'mywidget'
);
return '<div class="mywidget" data-per-page="' + $args['per_page'] + '">My widget</div>';
});
Widget from above example can be inserted by
[mywidget per_page=20]
shortcode in block editor.