Support » Plugins » Meta box does not appear in a custom post type.

  • I am trying to create a custom post type for products of a company with a text box to add the price. But no matter what I try, the meta box does not show up. Could any one help me? The code I used is,

    class vp_serivce_post{
        public function __construct() {
    //        set_post_thumbnail_size( 80, 80, true );
        public function ser_registar(){
            $args = array(
                'labels' => array(
                    'name' => 'Products',
                    'singular_name' => 'Product',
                    'add_new' => 'Add New Product',
                    'add_new_item' => 'Add New Product',
                    'edit_item' => 'Edit Product',
                    'new_item' => 'New Product',
                    'all_items' => 'All Products',
                    'view_item' => 'View Product',
                    'search_items' => 'Search Products',
                    'not_found' => 'No Product Found',
                    'not_found_in_trash' => 'No Product Found in Trash',
                    'menu_name' => 'Products'
                query_var => 'products',
                rewrite => array(
                    slug => 'products/'
                'public' => true,
                //'menu_position' => 25,
                'supports' => array(
        public function price_box(){
            add_action('add_meta_boxes', 'add_price_box');
            function add_price_box(){
                add_meta_box('price_id', 'Price', 'price_add', 'vp_price');
                function price_add($post){
    <label for="vp_price">Price: </label>
    <input type="text" class="widefat" name="vp_price" id="vp_price" vlaue="<?php echo esc_attr($length); ?>" />
    add_action('init', 'post_invok');
    function post_invok(){
        new vp_serivce_post();
  • The topic ‘Meta box does not appear in a custom post type.’ is closed to new replies.