Advertisement
Guest User

Untitled

a guest
Sep 15th, 2019
191
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.95 KB | None | 0 0
  1. add_filter( 'rwmb_meta_boxes', 'your_prefix_register_meta_boxes' );
  2.  
  3. function your_prefix_register_meta_boxes( $meta_boxes ) {
  4.     $post_type = $post_author = $post_date = '';
  5.     $post_id   = isset( $_GET['post'] ) ? (int) $_GET['post'] : null;
  6.     if ( $post_id ) {
  7.         $post        = get_post( $post_id );
  8.         $post_type   = $post->post_type;
  9.         $post_author = $post->post_author;
  10.         $post_date   = date( 'Y-m-d', strtotime( $post->post_date ) );
  11.     }
  12.    
  13.     $prefix = '';
  14.  
  15.     $meta_boxes[] = array (
  16.         'title' => esc_html__( 'Campos de filtración', 'text-domain' ),
  17.         'id' => 'campos-de-filtracion',
  18.         'post_types' => array(
  19.             0 => 'noticias',
  20.             1 => 'articulos',
  21.             2 => 'cuentos',
  22.             3 => 'estudios',
  23.             4 => 'regalos',
  24.             5 => 'encuestas',
  25.             6 => 'ejercicios-web',
  26.             7 => 'podcasts',
  27.             8 => 'webcasts',
  28.             9 => 'seminarios-web',
  29.             10 => 'reciclados',
  30.         ),
  31.         'context' => 'normal',
  32.         'priority' => 'high',
  33.         'fields' => array(
  34.             array (
  35.                 'id' => $prefix . 'text_sfzlrrqoz5d',
  36.                 'type' => 'text',
  37.                 'name' => esc_html__( 'Tipo de publicación', 'text-domain' ),
  38.                 'required' => 1,
  39.             ),
  40.             array (
  41.                 'id' => $prefix . 'date_1cpjomreww5',
  42.                 'type' => 'date',
  43.                 'name' => esc_html__( 'Fecha de publicación', 'text-domain' ),
  44.                 'required' => 1,
  45.             ),
  46.             array (
  47.                 'id' => $prefix . 'user_75nelpiq4a',
  48.                 'type' => 'user',
  49.                 'name' => esc_html__( 'Autor de la publicación', 'text-domain' ),
  50.                 'field_type' => 'select_advanced',
  51.                 'multiple' => true,
  52.                 'required' => 1,
  53.             ),
  54.         ),
  55.     );
  56.  
  57.     return $meta_boxes;
  58. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement