2

I'm using the class My Metabox class

*-- Custom Post Init Begin --*/  

function mypost_types(){
    register_post_type('video', 
    array(
        $labels = array(
            'name' => __( 'video' ),
            singular_name' => __( 'video'),
            'add_new_item' =>__('Add New video'),
            'edit_item' => __('Edit video'),
            'view_item' => __('View video')
        ),

        'labels' => $labels,
        'public' => true,
        'show_ui' => true,
        'capability_type' => 'post',
        'supports' =>  array('title','editor','excerpt','thumbnail','custom-fields')
    );
}   
add_action('init', 'mypost_types');

________second version after @kaiser comment

/*-- Custom Post Init Begin --*/  

`

 function mypost_types(){
{ 
$labels = array(
'name' => __( 'video' ),
'singular_name' => __( 'video' ),
'add_new_item' =>__('Add New video'),
'edit_item' => __('Edit video'),
'view_item' => __('View video')
);
$args = array(
'labels' => $labels,
    'public' => true,
    'show_ui' => true,
    'capability_type' => 'post',
    'supports' =>     array('title','editor','excerpt','thumbnail','custom-fields')
     );

    register_post_type('video', $args);
}   
      add_action('init', 'mypost_types');`

I have a problem to add this class in register_post_type. Does anybody know how to implement it?

Thanks.

7
  • More details + code please.
    – kaiser
    Mar 29 '12 at 18:34
  • Could you please edit the Q and format the code properly? Thanks.
    – kaiser
    Mar 29 '12 at 22:21
  • i put the code in the first comment i hope it is fine, thanks
    – teo
    Mar 29 '12 at 23:24
  • I reformated it. The problems start with missing quotes, assigning $label during calling the register_post_type function and such. Please fix this, read about WP_DEBUG, then come back and show your error messages.
    – kaiser
    Mar 29 '12 at 23:40
  • i put the code in the main comment see => second version
    – teo
    Mar 30 '12 at 0:14
1

it says right in the instructions that you just include the class

//include the main class file
require_once("meta-box-class/my-meta-box-class.php");

you'd put that in whatever file you are using for the code blocks you posted... not in the function you've written.

looks like there is a pretty good section called "Usage" at the link you provided. you should re-read that and revise your question to explain more clearly what your problem is that is not answered by the provided documentation.

2
  • thanks but i read it and do as the "usage doc" show but i think the main problem is in my cutom post declaration.
    – teo
    Mar 30 '12 at 13:21
  • doesn't look like there is anything wrong with your custom post type declaration. and it isn't really related to your usage of the metabox anyway. you can copy and paste the sample code provided in the documentation. there's ONE section that you will need to change to get a metabox on your post type. in the $config array, the sample has an array for the 'pages' value. you'll need to change that to array('video') Apr 2 '12 at 14:14

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.