plugin development – add_filter postbox_classes multiple post types

Question

I am trying to add classes to my metabox. How could I apply this to both post and pages? $posts variable? Do I need to add filter twice, once for each post type?

    $id = 'my-metabox-api';
    $posts = array('post', 'page');
    add_meta_box($id, 'My Video Player', 'add_metabox_api', $posts, 'normal', 'low'); 

    add_filter( "postbox_classes_{$posts}_{$id}", 'my_custom_mb' );

function my_custom_mb( $classes ) {
    array_push( $classes, 'closed' );
    return $classes;
}

0
Toniq 3 weeks 2021-11-06T15:55:56-05:00 0 Answers 0 views 0

Leave an answer

Browse
Browse