0
votes

How I can use custom metabox for page and post. Here is my code for page only.

function add_homepage_meta_box() {  
    global $post;

    $post_id = $post->ID;

        add_meta_box(  
            'homepage_meta_box', // $id  
            'Optional Full Width Slider', // $title  
            'show_homepage_meta_box', // $callback  
            'page', // $page  
            'normal', // $context  
            'high'); // $priority  
}
1
how to display metabox on posts and pages. currently using above snippet it is only display on pages. - fysalyaqoob

1 Answers

0
votes

Like so:

function add_homepage_meta_box() {
    $screens = array( 'post', 'page' );

    foreach ( $screens as $screen ) {
        add_meta_box(  
            'homepage_meta_box',
            'Optional Full Width Slider',
            'show_homepage_meta_box',
            $screen,
            'normal',
            'high'
        );      
    }
}