Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Register a block for Gutenberg
- add_filter( 'rwmb_meta_boxes', function( $meta_boxes ) {
- $meta_boxes[] = [
- 'title' => 'VIEW Post Picker',
- 'id' => 'view-post-picker',
- 'type' => 'block', // Important.
- 'icon' => 'admin-post', // Or you can set a custom SVG if you don't like Dashicons
- 'category' => 'text',
- //'context' => 'side', // The block settings will be available on the right sidebar.
- 'mode' => 'edit', //The default mode of the block: edit to make it shows the edit fields when loaded, preview (default) to show the rendered HTML when loaded.
- //'render_template' => get_stylesheet_directory() . '/blocks/hero/template.php', // The PHP template that renders the block.
- //'enqueue_style' => get_stylesheet_directory_uri() . '/blocks/hero/style.css', // CSS file for the block.
- // Now register the block fields.
- 'fields' => [
- [
- 'id' => 'vpp_post',
- 'type' => 'post',
- 'name' => 'Post or Page?',
- 'post_type' => ['post','page'],
- 'field_type' => 'select_advanced',
- ],
- [
- 'id' => 'vpp_attachment',
- 'type' => 'post',
- 'name' => 'Attachment?',
- 'post_type' => 'attachment',
- 'field_type' => 'select_advanced',
- 'query_args' => [
- 'post_status' => ['publish','inherit'],
- 'posts_per_page' => - 1,
- ],
- ],
- ],
- ];
- return $meta_boxes;
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement