Closed mohamedhamad closed 9 years ago
An options array can now be passed to define extra details of a post type and a taxonomy.
eg: Post Type, you can now pass an array to define menu_icon, rewrite, archive settings, search exclusion.
WordPress_Plugin_Template()->register_post_type( 'post_type', __( 'Plural Name', 'wordpress-plugin-template' ), __( 'Singular Name', 'wordpress-plugin-template' ), __( 'Description', 'wordpress-plugin-template'), array( 'menu_icon'=>plugins_url( 'assets/img/cpt-icon.png', __FILE__ ), 'rewrite' => array('slug' =>'post_type_slug'), 'exclude_from_search' => false, 'has_archive' => true, 'supports' => array( 'title', 'editor', 'excerpt', 'thumbnail', 'page-attributes' ), ) );
eg: Taxonomy hierarchical options to differentiate between a category or tag type taxonomy, rewrite options with slug and hierarchical display
WordPress_Plugin_Template()->register_taxonomy( 'taxonomy_name', __( 'Plural Name', 'wordpress-plugin-template' ), __( 'Singular Name', 'wordpress-plugin-template' ), 'post_type', array( 'hierarchical'=>false, 'rewrite'=>array('slug'=>'taxonomy_slug', 'hierarchical' => true), ) );
This is very cool - thanks for the working on this and contributing it back! :)
glad to help. use this all the time. would love to contribute more.
An options array can now be passed to define extra details of a post type and a taxonomy.
eg: Post Type, you can now pass an array to define menu_icon, rewrite, archive settings, search exclusion.
eg: Taxonomy hierarchical options to differentiate between a category or tag type taxonomy, rewrite options with slug and hierarchical display