dimanche 8 novembre 2015

Registering custom made plugin into custom post type

I made a custom plugin which contains some meta boxes which I want to implement in a custom post type, but I can not find any documentation on that on the web.

This is my function for registering custom post type.

   function models_post_type() {
    $labels = array (
        'name'                  => _x( 'Models', 'Post Type General Name', 'basicmodels' ),
        'singular_name'         => _x( 'Model', 'Post Type Singular Name', 'basicmodels' ),
        'menu_name'             => __( 'Models', 'basicmodels' ),
        'parent_item_colon'     => __( 'Parent Model', 'basicmodels' ),
        'all_items'             => __( 'All Models', 'basicmodels' ),
        'view_item'             => __( 'View Model', 'basicmodels' ),
        'add_new_item'          => __( 'Add New Model', 'basicmodels' ),
        'add_new'               => __( 'Add New', 'basicmodels' ),
        'edit_item'             => __( 'Edit Model', 'basicmodels' ),
        'update_item'           => __( 'Update model', 'basicmodels' ),
        'search_items'          => __( 'Search Model', 'basicmodels' ),
        'not_found'             => __( 'Model Not Found', 'basicmodels' ),
        'not_found_in_trash'    => __( 'Not Found In Trash', 'basicmodels' ),
    );

    $args = array (
        'label'                 => __( 'Models', 'basicmodels' ),
        'description'           => __( 'Lista modela i informacije', 'basicmodels' ),
        'labels'                => $labels,
        'supports'              => array( 'title', 'editor', 'excerpt', 'thumbnail', 'revisions' ),
        'hierarchical'          => false,
        'public'                => true,
        'show_ui'               => true,
        'show_in_menu'          => true,
        'show_in_nav_menus'     => true,
        'show_in_admin_bar'     => true,
        'menu_position'         => 5,
        'can_export'            => true,
        'has_archive'           => true,
        'exclude_from_search'   => false,
        'publicly_queryable'    => true,
        'capability_type'       => 'page',
    );

    register_post_type( 'models', $args );
}

add_action( 'init', 'models_post_type' );

And my plugin is working perfectly, so I think I do not need to post code. What should I add in 'supports' to implement my plugin in my post type?

I've tried adding 'custom-fields' into supports, but I get a lot of custom fields and not my plugin.



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire