jeudi 3 décembre 2015

How to create a complete plugins using WP custom post type

I want to create a WP custom post type plugins. I have tried with ACF plugins and its generated the custom fields : http://ift.tt/21ydy5H .

I do not know how to create an independent plugins using above generated filed and not using ACF plugin.

I have tried with below code and don't know how to proceed further.

 <?php 
/*Plugin Name: CNSLounge
Description: This plugin registers the 'Authors CNSLounge' post type.
Version: 1.0
License: GPLv2
*/


// Register Custom Post Type
function CNSLounge() {

    $labels = array(
        'name'                  => _x( 'Authorz', 'Post Type General Name', 'text_domain' ),
        'singular_name'         => _x( 'Authorz', 'Post Type Singular Name', 'text_domain' ),
        'menu_name'             => __( 'Authorz', 'text_domain' ),
        'name_admin_bar'        => __( 'Authorz', 'text_domain' ),
        'parent_item_colon'     => __( 'Parent Item:', 'text_domain' ),
        'all_items'             => __( 'All Items', 'text_domain' ),
        'add_new_item'          => __( 'Add New Authorz', 'text_domain' ),
        'add_new'               => __( 'Add Authorz', 'text_domain' ),
        'new_item'              => __( 'New Authorz', 'text_domain' ),
        'edit_item'             => __( 'Edit Authorz', 'text_domain' ),
        'update_item'           => __( 'Update Authorz', 'text_domain' ),
        'view_item'             => __( 'View Authorz', 'text_domain' ),
        'search_items'          => __( 'Search Authorz', 'text_domain' ),
        'not_found'             => __( 'Not found', 'text_domain' ),
        'not_found_in_trash'    => __( 'Not found in Trash', 'text_domain' ),
        'items_list'            => __( 'Authorz list', 'text_domain' ),
        'items_list_navigation' => __( 'Items list navigation', 'text_domain' ),
        'filter_items_list'     => __( 'Filter items list', 'text_domain' ),
    );
    $args = array(
        'label'                 => __( 'Authorz', 'text_domain' ),
        'description'           => __( 'CNS Authorz  Lounge', 'text_domain' ),
        'labels'                => $labels,
        'supports'              => array( 'title', 'editor', 'excerpt', 'revisions', 'custom-fields', 'page-attributes', 'post-formats', ),
        'taxonomies'            => array( 'category', 'post_tag' ),
        'hierarchical'          => false,
        'public'                => true,
        'show_ui'               => true,
        'show_in_menu'          => true,
        'menu_position'         => 5,
        'menu_icon'             => 'dashicons-universal-access-alt',
        'show_in_admin_bar'     => true,
        'show_in_nav_menus'     => true,
        'can_export'            => true,
        'has_archive'           => false,       
        'exclude_from_search'   => false,
        'publicly_queryable'    => true,
        'capability_type'       => 'post',
    );
    register_post_type( 'post_type', $args );

}
add_action( 'init', 'CNSLounge', 0 );





?>



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire