Home / Woo-Commerce / How to Creating a Custom Post Type for product, slider, portfolio or News Sections in wordpress or Woocommerce

How to Creating a Custom Post Type for product, slider, portfolio or News Sections in wordpress or Woocommerce

Copy and paste the code in functions.php

function my_custom_post_product() {
$args = array();
register_post_type( 'product', $args );
}
add_action( 'init', 'my_custom_post_product' );
<?php

function my_custom_post_product() {
$labels = array(
'name' => _x( 'Products', 'post type general name' ),
'singular_name' => _x( 'Product', 'post type singular name' ),
'add_new' => _x( 'Add New', 'book' ),
'add_new_item' => __( 'Add New Product' ),
'edit_item' => __( 'Edit Product' ),
'new_item' => __( 'New Product' ),
'all_items' => __( 'All Products' ),
'view_item' => __( 'View Product' ),
'search_items' => __( 'Search Products' ),
'not_found' => __( 'No products found' ),
'not_found_in_trash' => __( 'No products found in the Trash' ),
'parent_item_colon' => '',
'menu_name' => 'Products'
);
$args = array(
'labels' => $labels,
'description' => 'Holds our products and product specific data',
'public' => true,
'menu_position' => 5,
'supports' => array( 'title', 'editor', 'thumbnail', 'excerpt', 'comments' ),
'has_archive' => true,
);
register_post_type( 'product', $args );
}
add_action( 'init', 'my_custom_post_product' );

?>

Custom Taxonomies

function my_taxonomies_product() {
$args = array();
register_taxonomy( 'product_category', 'product' $args );
}

add_action( 'init', 'my_taxonomies_product', 0 );
<?php

function my_taxonomies_product() {
$labels = array(
'name' => _x( 'Product Categories', 'taxonomy general name' ),
'singular_name' => _x( 'Product Category', 'taxonomy singular name' ),
'search_items' => __( 'Search Product Categories' ),
'all_items' => __( 'All Product Categories' ),
'parent_item' => __( 'Parent Product Category' ),
'parent_item_colon' => __( 'Parent Product Category:' ),
'edit_item' => __( 'Edit Product Category' ),
'update_item' => __( 'Update Product Category' ),
'add_new_item' => __( 'Add New Product Category' ),
'new_item_name' => __( 'New Product Category' ),
'menu_name' => __( 'Product Categories' ),
);
$args = array(
'labels' => $labels,
'hierarchical' => true,
);
register_taxonomy( 'product_category', 'product', $args );
}
add_action( 'init', 'my_taxonomies_product', 0 );

?>

Thanks Guys.

About Sushil_kumar

Check Also

Jevelin v2.4.12 – Responsive Multi-Purpose WordPress Theme

Download Jevelin v2.4.12 | Themeforest Responsive Multi-Purpose WordPress Theme Jevelin v2.4.12 is one of the most popular multi-purpose WordPress themes available today, users have consistently given Jevelin positive ratings. With a growing library of high-quality, professional website designs ready to be imported into your WordPress site in just a few clicks, Jevelin can help you […] The post Jevelin v2.4.12 – Responsive Multi-Purpose WordPress Theme appeared first on Themes24x7 - Free Premium Blogger and Wordpress Templates. http://www.sushilkumar.ind.in...

Leave a Reply

Your email address will not be published. Required fields are marked *

Engineer Sushil Kumar is Stephen Fry proof thanks to caching by WP Super Cache