{"id":569,"date":"2016-03-17T15:29:21","date_gmt":"2016-03-17T15:29:21","guid":{"rendered":"https:\/\/www.sushilkumar.ind.in\/blog\/?p=569"},"modified":"2016-03-17T16:01:03","modified_gmt":"2016-03-17T16:01:03","slug":"how-to-creating-a-custom-post-type-for-product-slider-portfolio-or-news-sections-in-wordpress-or-woocommerce","status":"publish","type":"post","link":"https:\/\/www.sushilkumar.ind.in\/blog\/wordpress\/how-to-creating-a-custom-post-type-for-product-slider-portfolio-or-news-sections-in-wordpress-or-woocommerce\/","title":{"rendered":"How to Creating a Custom Post Type for product, slider, portfolio or News Sections in wordpress or Woocommerce"},"content":{"rendered":"<h3>Copy and paste the code in functions.php<\/h3>\n<pre>function my_custom_post_product() {\r\n$args = array();\r\nregister_post_type( 'product', $args );\r\n}\r\nadd_action( 'init', 'my_custom_post_product' );\r\n<\/pre>\n<pre>&lt;?php\r\n\r\nfunction my_custom_post_product() {\r\n$labels = array(\r\n'name' =&gt; _x( 'Products', 'post type general name' ),\r\n'singular_name' =&gt; _x( 'Product', 'post type singular name' ),\r\n'add_new' =&gt; _x( 'Add New', 'book' ),\r\n'add_new_item' =&gt; __( 'Add New Product' ),\r\n'edit_item' =&gt; __( 'Edit Product' ),\r\n'new_item' =&gt; __( 'New Product' ),\r\n'all_items' =&gt; __( 'All Products' ),\r\n'view_item' =&gt; __( 'View Product' ),\r\n'search_items' =&gt; __( 'Search Products' ),\r\n'not_found' =&gt; __( 'No products found' ),\r\n'not_found_in_trash' =&gt; __( 'No products found in the Trash' ),\r\n'parent_item_colon' =&gt; '',\r\n'menu_name' =&gt; 'Products'\r\n);\r\n$args = array(\r\n'labels' =&gt; $labels,\r\n'description' =&gt; 'Holds our products and product specific data',\r\n'public' =&gt; true,\r\n'menu_position' =&gt; 5,\r\n'supports' =&gt; array( 'title', 'editor', 'thumbnail', 'excerpt', 'comments' ),\r\n'has_archive' =&gt; true,\r\n);\r\nregister_post_type( 'product', $args );\r\n}\r\nadd_action( 'init', 'my_custom_post_product' );\r\n\r\n?&gt;\r\n<\/pre>\n<h2>Custom Taxonomies<\/h2>\n<pre>function my_taxonomies_product() {\r\n$args = array();\r\nregister_taxonomy( 'product_category', 'product' $args );\r\n}\r\n\r\nadd_action( 'init', 'my_taxonomies_product', 0 );\r\n<\/pre>\n<pre>\r\n&lt;?php\r\n\r\nfunction my_taxonomies_product() {\r\n$labels = array(\r\n'name' =&gt; _x( 'Product Categories', 'taxonomy general name' ),\r\n'singular_name' =&gt; _x( 'Product Category', 'taxonomy singular name' ),\r\n'search_items' =&gt; __( 'Search Product Categories' ),\r\n'all_items' =&gt; __( 'All Product Categories' ),\r\n'parent_item' =&gt; __( 'Parent Product Category' ),\r\n'parent_item_colon' =&gt; __( 'Parent Product Category:' ),\r\n'edit_item' =&gt; __( 'Edit Product Category' ),\r\n'update_item' =&gt; __( 'Update Product Category' ),\r\n'add_new_item' =&gt; __( 'Add New Product Category' ),\r\n'new_item_name' =&gt; __( 'New Product Category' ),\r\n'menu_name' =&gt; __( 'Product Categories' ),\r\n);\r\n$args = array(\r\n'labels' =&gt; $labels,\r\n'hierarchical' =&gt; true,\r\n);\r\nregister_taxonomy( 'product_category', 'product', $args );\r\n}\r\nadd_action( 'init', 'my_taxonomies_product', 0 );\r\n\r\n?&gt;\r\n<\/pre>\n<p>Thanks Guys.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Copy and paste the code in functions.php function my_custom_post_product() { $args = array(); register_post_type( &#8216;product&#8217;, $args ); } add_action( &#8216;init&#8217;, &#8216;my_custom_post_product&#8217; ); &lt;?php function my_custom_post_product() { $labels = array( &#8216;name&#8217; =&gt; _x( &#8216;Products&#8217;, &#8216;post type general name&#8217; ), &#8216;singular_name&#8217; =&gt; _x( &#8216;Product&#8217;, &#8216;post type singular name&#8217; ), &#8216;add_new&#8217; =&gt; _x( &#8216;Add New&#8217;, &#8216;book&#8217; ), &#8216;add_new_item&#8217; &hellip;<\/p>\n","protected":false},"author":1,"featured_media":570,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":false,"jetpack_social_options":{"image_generator_settings":{"template":"highway","enabled":false},"version":2}},"categories":[54,13],"tags":[72,76,77,74,75,73],"class_list":["post-569","post","type-post","status-publish","format-standard","has-post-thumbnail","","category-woo-commerce","category-wordpress","tag-custom-post-type","tag-custom-post-type-for-news","tag-custom-post-type-for-portfolio","tag-custom-post-type-for-products","tag-custom-post-type-for-sliders","tag-custom-post-type-in-wordpress"],"jetpack_publicize_connections":[],"acf":[],"aioseo_notices":[],"jetpack_featured_media_url":"https:\/\/www.sushilkumar.ind.in\/blog\/wp-content\/uploads\/2016\/03\/custom_post_type.png","jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/p99pkJ-9b","_links":{"self":[{"href":"https:\/\/www.sushilkumar.ind.in\/blog\/wp-json\/wp\/v2\/posts\/569"}],"collection":[{"href":"https:\/\/www.sushilkumar.ind.in\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.sushilkumar.ind.in\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.sushilkumar.ind.in\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.sushilkumar.ind.in\/blog\/wp-json\/wp\/v2\/comments?post=569"}],"version-history":[{"count":0,"href":"https:\/\/www.sushilkumar.ind.in\/blog\/wp-json\/wp\/v2\/posts\/569\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.sushilkumar.ind.in\/blog\/wp-json\/wp\/v2\/media\/570"}],"wp:attachment":[{"href":"https:\/\/www.sushilkumar.ind.in\/blog\/wp-json\/wp\/v2\/media?parent=569"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.sushilkumar.ind.in\/blog\/wp-json\/wp\/v2\/categories?post=569"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.sushilkumar.ind.in\/blog\/wp-json\/wp\/v2\/tags?post=569"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}