Advertisement
DidouS

metabox code example

Jul 6th, 2020
1,036
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.39 KB | None | 0 0
  1. add_filter( 'rwmb_meta_boxes' , function ($meta_boxes ) {
  2.  
  3.     $myblock = [
  4.         'title'           => 'Hero Content',
  5.         'id'              => 'hero-content',
  6.         'description'     => 'A custom hero content block',
  7.         'type'            => 'block',
  8.         'icon'            => 'awards',
  9.         'category'        => 'layout',
  10.         'context'         => 'side',
  11.         'render_template' => get_template_directory() . '/dummy.php',
  12.         //'enqueue_style'   => get_template_directory_uri() . '/blocks/hero/style.css',
  13.         'supports' => [
  14.             'align' => ['wide', 'full'],
  15.         ],
  16.  
  17.         // Block fields.
  18.         'fields'          => [
  19.             [
  20.                 'type' => 'single_image',
  21.                 'id'   => 'image',
  22.                 'name' => 'Image',
  23.             ],
  24.             [
  25.                 'type' => 'text',
  26.                 'id'   => 'title',
  27.                 'name' => 'Title',
  28.             ],
  29.             [
  30.                 'type' => 'text',
  31.                 'id'   => 'subtitle',
  32.                 'name' => 'Subtitle',
  33.             ],
  34.             [
  35.                 'type' => 'textarea',
  36.                 'id'   => 'content',
  37.                 'name' => 'Content',
  38.             ],
  39.             [
  40.                 'type' => 'single_image',
  41.                 'id'   => 'signature',
  42.                 'name' => 'Signature',
  43.             ],
  44.             [
  45.                 'type' => 'text',
  46.                 'id'   => 'button_text',
  47.                 'name' => 'Button Text',
  48.             ],
  49.             [
  50.                 'type' => 'text',
  51.                 'id'   => 'button_url',
  52.                 'name' => 'Button URL',
  53.             ],
  54.             [
  55.                 'type' => 'color',
  56.                 'id'   => 'background_color',
  57.                 'name' => 'Background Color',
  58.             ],
  59.         ],
  60.     ];
  61.  
  62.     $meta_boxes[] = $myblock;
  63.  
  64.     return $meta_boxes;
  65. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement