WordPress Custom Post With Tag And Category Support

/* Custom Product support with tags & categories Post */
register_post_type( ‘product’, /* seen at the URL as a parameter and a unique id for the custom post */
array(
‘labels’ => array(
‘name’ => __( ‘Product’,’Product’ ), /* The Label of the custom post */
‘singular_name’ => __( “Product”, ‘oudarya_textdomain’ ), /* The Label of the custom post */
‘add_new’ => __( ‘Add New’, ‘Product’, ‘oudarya_textdomain’ ),
‘add_new_item’ => __( ‘Add New Product’, ‘oudarya_textdomain’ ),
‘new_item’ => __( ‘New Product’, ‘oudarya_textdomain’ ),
‘edit_item’ => __( ‘Edit Product’, ‘oudarya_textdomain’ ),
‘view_item’ => __( ‘View Product’, ‘oudarya_textdomain’ ),
‘all_items’ => __( ‘All Product’, ‘oudarya_textdomain’ )
),
‘public’ => true,
‘menu_icon’ => ‘dashicons-cart’,
‘has_archive’ => true,
‘rewrite’ => array(‘slug’ => ‘product’), /* The slug of the custom post */
‘taxonomies’ => array(‘post_tag’),
‘supports’ => array( ‘title’, ‘editor’, ‘thumbnail’,’post-formats’), /* enable basic for text editing */
)
);
function wpb_change_title_text_product( $title ){
$screen = get_current_screen();
if ( ‘product’ == $screen->post_type ) {
$title = ‘Enter products title here’;
}
return $title;
}
add_filter( ‘enter_title_here’, ‘wpb_change_title_text_product’ );
function add_tags_categories() {
//register_taxonomy_for_object_type(‘p_category’, ‘product’);
register_taxonomy_for_object_type(‘post_tag’, ‘product’);
}
add_action(‘init’, ‘add_tags_categories’);
/* Product Taxonomy */
function product_taxonomie() {
register_taxonomy(
‘product’,
array( ‘product’ ),
array(
‘public’ => true,
‘show_ui’ => true,
‘show_tagcloud’ => false,
‘hierarchical’ => true,
‘labels’ => array(
‘name’ => __( ‘Product Category’, ‘textdomain_oudarya’ ),
‘singular_name’ => __( ‘Product Category’, ‘textdomain_oudarya’ )
),
)
);
}
add_action( ‘init’, ‘product_taxonomie’, 0 );

Advertisements

Published by

oudarya

I am a developer

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s