{"id":390230,"date":"2024-04-02T11:50:40","date_gmt":"2024-04-02T11:50:40","guid":{"rendered":"https:\/\/webkul.com\/blog\/?p=390230"},"modified":"2025-01-15T15:13:52","modified_gmt":"2025-01-15T15:13:52","slug":"create-attributes-woocommerce-programmatically","status":"publish","type":"post","link":"https:\/\/webkul.com\/blog\/create-attributes-woocommerce-programmatically\/","title":{"rendered":"How To Create Attributes In WooCommerce Programmatically?"},"content":{"rendered":"\n<p>In this blog, we will see how to create attributes in WooCommerce with coding.<\/p>\n\n\n\n<p>Before proceeding further we should know what are WooCommerce attributes. In WooCommerce, you can add information to your products through attributes. <\/p>\n\n\n\n<p>These features depend on the product. For example, common attributes for clothing items are size and color.<\/p>\n\n\n\n<p>You can also go through the creation of a WooCommerce <a href=\"https:\/\/webkul.com\/blog\/woocommerce-product-attributes-lookup-table\/\" target=\"_blank\" rel=\"noreferrer noopener\">Product attribute lookup table<\/a>.<\/p>\n\n\n\n<p>The interesting thing about attributes is that they are global. Instead of applying them to every product, you simply create them and add them to different products. <\/p>\n\n\n\n<p>You can also check our <a href=\"https:\/\/store.webkul.com\/woocommerce-plugins.html\" target=\"_blank\" rel=\"noreferrer noopener\">WooCommerce plugin<\/a> that can help you achieve most of the required features and functionalities. <\/p>\n\n\n\n<p>Attributes are essential for:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Variable products:<\/strong> Before creating variable products, you have to define attributes for them. This allows you to add variations of the product.<\/li>\n\n\n\n<li><strong>Filtering products:<\/strong> A common way of filtering is based on attributes. For example, a user may be looking for a 15-inch screen laptop.<\/li>\n<\/ul>\n\n\n\n<p>Now that we have a better understanding of attributes, let&#8217;s see how to add product attributes in WooCommerce.<\/p>\n\n\n\n<div class=\"wk-index-wrap\"><div class=\"block-wrap\">\n<h3 class=\"wp-block-heading index-title\">Step 1: Create a Custom Plugin<\/h3>\n<\/div><\/div>\n\n\n\n<p>First of all, create a directory for your new WooCommerce plugin in the plugins directory path i.e. \u2018\/wp-content\/plugins\/\u2019.<\/p>\n\n\n\n<p>In my case, the directory name is \u2018wkwc-add-custom-atrributes\u2019 you can change your directory name as you want.<\/p>\n\n\n\n<p>Next, Open this folder in your preferred text editor and create a php file like \u2018\u2018wkwc-add-custom-atrributes.php\u2019.<\/p>\n\n\n\n<p>You can check more about <a href=\"https:\/\/woo.com\/document\/managing-product-taxonomies\/\" target=\"_blank\" rel=\"noreferrer noopener nofollow\">managing product taxonomies<\/a> and <a href=\"https:\/\/developer.woocommerce.com\/2022\/02\/02\/new-product-filtering-by-attributes-rolling-out-in-woocommerce-6-3\/\" target=\"_blank\" rel=\"noreferrer noopener nofollow\">filter products by attribute<\/a> for a better understanding.<\/p>\n\n\n\n<p>Put the following header comments in the PHP file to make this a plugin file.<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\">\/**\n * Plugin Name: WooCommerce Create Attributes\n * Description: This will create a attribute of the product.\n * Author: Webkul\n * Author URI: https:\/\/webkul.com\/\n * Version: 1.0.0\n * Text Domain: wkwc-attribute\n *\n * @package WooCommerce Create Attributes\n *\/<\/pre>\n\n\n\n<p>You can change the above information to match your details.<\/p>\n\n\n\n<div class=\"wk-index-wrap\"><div class=\"block-wrap\">\n<h3 class=\"wp-block-heading index-title\">Step 2: Add the following code to the plugin&#8217;s main file.<\/h3>\n<\/div><\/div>\n\n\n\n<pre class=\"EnlighterJSRAW\">\/\/ This hook is triggered before any other hook when a user accesses the admin area.\nadd_action(&#039;admin_init&#039;, &#039;wkwc_add_product_attributes&#039;);\n\nfunction wkwc_add_product_attributes() {\n    $atts=array(\n        &#039;price&#039; =&gt;array(&#039;&lt; 50000&#039;,&#039;&gt; 50000&#039;, &#039;= 50000&#039;),\n        &#039;brand&#039; =&gt;array(&#039;hp&#039;,&#039;dell&#039;,&#039;apple&#039;),\n    );\n\n    foreach ( $atts as $key =&gt; $values ) {\n       new Wkwc_Add_Attribute( $key, $values );\n    }\n}\n\n\/**\n * Add attribute class.\n *\/\nclass Wkwc_Add_Attribute{\n\n    \/**\n\t * Constructor of this class.\n\t *\/\n    public function __construct( $name, $val ) {\n\n\t\t$attrs = array();\n\t\t$attributes = wc_get_attribute_taxonomies();\n\n\t\tforeach ( $attributes as $key =&gt; $value ) {\n\t\t\tarray_push( $attrs,$attributes&#091;$key]-&gt;attribute_name );\n\t\t}\n\n\t\tif ( ! in_array( $name, $attrs ) ) {\n\t\t\t$args = array(\n\t\t\t\t&#039;id&#039; =&gt; &#039;wkwc-custom-attribute&#039;,\n\t\t\t\t&#039;slug&#039;    =&gt; $name,\n\t\t\t\t&#039;name&#039;   =&gt; __( $name, &#039;wkwc-attribute&#039; ),\n\t\t\t\t&#039;type&#039;    =&gt; &#039;select&#039;,\n\t\t\t\t&#039;orderby&#039; =&gt; &#039;menu_order&#039;,\n\t\t\t\t&#039;has_archives&#039;  =&gt; false,\n\t\t\t\t&#039;limit&#039; =&gt; 1,\n\t\t\t\t&#039;is_in_stock&#039; =&gt; 1\n\t\t\t);\n\n\t\t\treturn wc_create_attribute( $args ); \/\/ Create the attribute.\n\t\t}\n\n\t\t$this-&gt;wkwc_add_var( $name, $val );\n    }\n\n\t\/**\n\t * Add all variations contained in the original array to the attribute, this is also passed through the function.\n\t *\n\t * @param string $name Attribute name.\n\t * @param string $val Attribute value.\n\t *\/\n\tpublic function wkwc_add_var( $name, $val ) {\n        $taxonomy = &#039;pa_&#039;.$name;\n        $term_slug = sanitize_title($name);\n\n        \/\/ Check if the term exist and if not it create it (and get the term ID).\n        for ($ff=0; $ff &lt; count($val) ; $ff++) {\n            if( ! term_exists( $val&#091;$ff], $taxonomy ) ){\n\t\t\t\t$term_data = wp_insert_term($val&#091;$ff], $taxonomy );\n\t\t\t\t$term_id = $term_data&#091;&#039;term_id&#039;];\n\t\t\t} else {\n\t\t\t\t$term_id = get_term_by( &#039;name&#039;, $val&#091;$ff], $taxonomy )-&gt;term_id;\n\t\t\t}\n\t\t}\n\t}\n}<\/pre>\n\n\n\n<div class=\"wk-index-wrap\"><div class=\"block-wrap\">\n<h3 class=\"wp-block-heading index-title\">Step 3: Save and activate the plugin<\/h3>\n<\/div><\/div>\n\n\n\n<p>Once you have added the code to the main plugin file, save the file and activate the plugin in the WordPress admin panel.<\/p>\n\n\n\n<p>To activate the plugin, go to the \u201cPlugins\u201d menu and find the plugin you just created. Click \u201cActivate\u201d to enable the plugin.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" width=\"1200\" height=\"318\" src=\"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2024\/04\/activate-plugin-woocommerce-attribute-1-1200x318.webp\" alt=\"Installed plugins page where we can see the installed plugins.\" class=\"wp-image-430909\" srcset=\"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2024\/04\/activate-plugin-woocommerce-attribute-1-1200x318.webp 1200w, https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2024\/04\/activate-plugin-woocommerce-attribute-1-300x79.webp 300w, https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2024\/04\/activate-plugin-woocommerce-attribute-1-250x66.webp 250w, https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2024\/04\/activate-plugin-woocommerce-attribute-1-768x203.webp 768w, https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2024\/04\/activate-plugin-woocommerce-attribute-1.webp 1353w\" sizes=\"(max-width: 1200px) 100vw, 1200px\" loading=\"lazy\" \/><\/figure>\n\n\n\n<p>Now, we can see the custom attributes in the <strong>Products &gt; Attributes.<\/strong><\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" width=\"1200\" height=\"452\" src=\"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2024\/04\/woocommerce-product-attribute-1-1200x452.webp\" alt=\"Attributes section where all product attributes are listed.\" class=\"wp-image-430908\" srcset=\"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2024\/04\/woocommerce-product-attribute-1-1200x452.webp 1200w, https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2024\/04\/woocommerce-product-attribute-1-300x113.webp 300w, https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2024\/04\/woocommerce-product-attribute-1-250x94.webp 250w, https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2024\/04\/woocommerce-product-attribute-1-768x289.webp 768w, https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2024\/04\/woocommerce-product-attribute-1.webp 1347w\" sizes=\"(max-width: 1200px) 100vw, 1200px\" loading=\"lazy\" \/><\/figure>\n\n\n\n<div class=\"wk-index-wrap\"><div class=\"block-wrap\">\n<h3 class=\"wp-block-heading index-title\">Step 4: Add the attribute to a product.<\/h3>\n<\/div><\/div>\n\n\n\n<p>Additionally, attributes for setting product variations will also be available on the product editor page:<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img decoding=\"async\" width=\"1040\" height=\"379\" src=\"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2024\/04\/product-editor-page-woocommerce-attribute-1.webp\" alt=\"Product editor page at which we can add the attribute on product.\" class=\"wp-image-430906\" srcset=\"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2024\/04\/product-editor-page-woocommerce-attribute-1.webp 1040w, https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2024\/04\/product-editor-page-woocommerce-attribute-1-300x109.webp 300w, https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2024\/04\/product-editor-page-woocommerce-attribute-1-250x91.webp 250w, https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2024\/04\/product-editor-page-woocommerce-attribute-1-768x280.webp 768w\" sizes=\"(max-width: 1040px) 100vw, 1040px\" loading=\"lazy\" \/><\/figure>\n\n\n\n<div class=\"wk-index-wrap\"><div class=\"block-wrap\">\n<h3 class=\"wp-block-heading index-title\">Step 5: WooCommerce Front-View<\/h3>\n<\/div><\/div>\n\n\n\n<p>On the front end, you can view your product attributes on the WooCommerce single product page. Here is the screenshot of your custom product attribute on the WooCommerce single product page:<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img decoding=\"async\" width=\"883\" height=\"519\" src=\"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2024\/04\/single-product-page-woocommerce-attribute-4.webp\" alt=\"Woocommerce single product page.\" class=\"wp-image-430899\" srcset=\"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2024\/04\/single-product-page-woocommerce-attribute-4.webp 883w, https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2024\/04\/single-product-page-woocommerce-attribute-4-300x176.webp 300w, https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2024\/04\/single-product-page-woocommerce-attribute-4-250x147.webp 250w, https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2024\/04\/single-product-page-woocommerce-attribute-4-768x451.webp 768w\" sizes=\"(max-width: 883px) 100vw, 883px\" loading=\"lazy\" \/><\/figure>\n\n\n\n<p>That\u2019s all about \u201cHow to create attributes in Woocommerce\u201d. Have a nice coding!<\/p>\n\n\n\n<div class=\"wk-index-wrap\"><div class=\"block-wrap\">\n<h3 class=\"wp-block-heading index-title\">Support<\/h3>\n<\/div><\/div>\n\n\n\n<p>If you need any technical assistance, please reach us by mail at support@webkul.com. <\/p>\n\n\n\n<p>Additionally, you can also <a href=\"https:\/\/webkul.com\/hire-woocommerce-developers\/\" target=\"_blank\" rel=\"noreferrer noopener\">Hire WooCommerce Developers<\/a> for your next project.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>In this blog, we will see how to create attributes in WooCommerce with coding. Before proceeding further we should know what are WooCommerce attributes. In WooCommerce, you can add information to your products through attributes. These features depend on the product. For example, common attributes for clothing items are size and color. You can also <a href=\"https:\/\/webkul.com\/blog\/create-attributes-woocommerce-programmatically\/\">[&#8230;]<\/a><\/p>\n","protected":false},"author":505,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[7966,1260,2805],"tags":[354],"class_list":["post-390230","post","type-post","status-publish","format-standard","hentry","category-wordpress-woocommerce","category-wordpress","category-wordpress-woocommerce-salesforce-connector","tag-attribute"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v24.5 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Create Attributes in WooCommerce Programmatically<\/title>\n<meta name=\"description\" content=\"Learn how to create attributes programmatically. This post covers step-by-step how to create attributes for your products with code.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/webkul.com\/blog\/create-attributes-woocommerce-programmatically\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Create Attributes in WooCommerce Programmatically\" \/>\n<meta property=\"og:description\" content=\"Learn how to create attributes programmatically. This post covers step-by-step how to create attributes for your products with code.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/webkul.com\/blog\/create-attributes-woocommerce-programmatically\/\" \/>\n<meta property=\"og:site_name\" content=\"Webkul Blog\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/webkul\/\" \/>\n<meta property=\"article:published_time\" content=\"2024-04-02T11:50:40+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2025-01-15T15:13:52+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/webkul.com\/blog\/wp-content\/uploads\/2024\/04\/activate-plugin-woocommerce-attribute-1-1200x318.webp\" \/>\n<meta name=\"author\" content=\"Raushan Kumar Paswan\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@webkul\" \/>\n<meta name=\"twitter:site\" content=\"@webkul\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Raushan Kumar Paswan\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"3 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/webkul.com\/blog\/create-attributes-woocommerce-programmatically\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/webkul.com\/blog\/create-attributes-woocommerce-programmatically\/\"},\"author\":{\"name\":\"Raushan Kumar Paswan\",\"@id\":\"https:\/\/webkul.com\/blog\/#\/schema\/person\/db36277344bb56e4917bf0211aec8793\"},\"headline\":\"How To Create Attributes In WooCommerce Programmatically?\",\"datePublished\":\"2024-04-02T11:50:40+00:00\",\"dateModified\":\"2025-01-15T15:13:52+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/webkul.com\/blog\/create-attributes-woocommerce-programmatically\/\"},\"wordCount\":457,\"commentCount\":2,\"publisher\":{\"@id\":\"https:\/\/webkul.com\/blog\/#organization\"},\"image\":{\"@id\":\"https:\/\/webkul.com\/blog\/create-attributes-woocommerce-programmatically\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/webkul.com\/blog\/wp-content\/uploads\/2024\/04\/activate-plugin-woocommerce-attribute-1-1200x318.webp\",\"keywords\":[\"Attribute\"],\"articleSection\":[\"WooCommerce\",\"WordPress\",\"Wordpress WooCommerce Salesforce Connector\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/webkul.com\/blog\/create-attributes-woocommerce-programmatically\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/webkul.com\/blog\/create-attributes-woocommerce-programmatically\/\",\"url\":\"https:\/\/webkul.com\/blog\/create-attributes-woocommerce-programmatically\/\",\"name\":\"Create Attributes in WooCommerce Programmatically\",\"isPartOf\":{\"@id\":\"https:\/\/webkul.com\/blog\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/webkul.com\/blog\/create-attributes-woocommerce-programmatically\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/webkul.com\/blog\/create-attributes-woocommerce-programmatically\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/webkul.com\/blog\/wp-content\/uploads\/2024\/04\/activate-plugin-woocommerce-attribute-1-1200x318.webp\",\"datePublished\":\"2024-04-02T11:50:40+00:00\",\"dateModified\":\"2025-01-15T15:13:52+00:00\",\"description\":\"Learn how to create attributes programmatically. This post covers step-by-step how to create attributes for your products with code.\",\"breadcrumb\":{\"@id\":\"https:\/\/webkul.com\/blog\/create-attributes-woocommerce-programmatically\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/webkul.com\/blog\/create-attributes-woocommerce-programmatically\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/webkul.com\/blog\/create-attributes-woocommerce-programmatically\/#primaryimage\",\"url\":\"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2024\/04\/activate-plugin-woocommerce-attribute-1.webp\",\"contentUrl\":\"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2024\/04\/activate-plugin-woocommerce-attribute-1.webp\",\"width\":1353,\"height\":358},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/webkul.com\/blog\/create-attributes-woocommerce-programmatically\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/webkul.com\/blog\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"How To Create Attributes In WooCommerce Programmatically?\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/webkul.com\/blog\/#website\",\"url\":\"https:\/\/webkul.com\/blog\/\",\"name\":\"Webkul Blog\",\"description\":\"\",\"publisher\":{\"@id\":\"https:\/\/webkul.com\/blog\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/webkul.com\/blog\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/webkul.com\/blog\/#organization\",\"name\":\"WebKul Software Private Limited\",\"url\":\"https:\/\/webkul.com\/blog\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/webkul.com\/blog\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2021\/08\/webkul-logo-accent-sq.png\",\"contentUrl\":\"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2021\/08\/webkul-logo-accent-sq.png\",\"width\":380,\"height\":380,\"caption\":\"WebKul Software Private Limited\"},\"image\":{\"@id\":\"https:\/\/webkul.com\/blog\/#\/schema\/logo\/image\/\"},\"sameAs\":[\"https:\/\/www.facebook.com\/webkul\/\",\"https:\/\/x.com\/webkul\",\"https:\/\/www.instagram.com\/webkul\/\",\"https:\/\/www.linkedin.com\/company\/webkul\",\"https:\/\/www.youtube.com\/user\/webkul\/\"]},{\"@type\":\"Person\",\"@id\":\"https:\/\/webkul.com\/blog\/#\/schema\/person\/db36277344bb56e4917bf0211aec8793\",\"name\":\"Raushan Kumar Paswan\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/webkul.com\/blog\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/ce9851ee21ba1ce546af25d566be4dffeaa3d4f8a1be72688619265ad326a321?s=96&d=https%3A%2F%2Fcdnblog.webkul.com%2Fblog%2Fwp-content%2Fuploads%2F2019%2F10%2Fmike.png&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/ce9851ee21ba1ce546af25d566be4dffeaa3d4f8a1be72688619265ad326a321?s=96&d=https%3A%2F%2Fcdnblog.webkul.com%2Fblog%2Fwp-content%2Fuploads%2F2019%2F10%2Fmike.png&r=g\",\"caption\":\"Raushan Kumar Paswan\"},\"description\":\"Raushan specializes in WordPress SaaS Development and Shipping Method services, delivering scalable solutions that streamline eCommerce operations. Expertise drives enhanced digital presence and empowers businesses to achieve sustained growth.\",\"url\":\"https:\/\/webkul.com\/blog\/author\/raushankrpaswan-wp333\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Create Attributes in WooCommerce Programmatically","description":"Learn how to create attributes programmatically. This post covers step-by-step how to create attributes for your products with code.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/webkul.com\/blog\/create-attributes-woocommerce-programmatically\/","og_locale":"en_US","og_type":"article","og_title":"Create Attributes in WooCommerce Programmatically","og_description":"Learn how to create attributes programmatically. This post covers step-by-step how to create attributes for your products with code.","og_url":"https:\/\/webkul.com\/blog\/create-attributes-woocommerce-programmatically\/","og_site_name":"Webkul Blog","article_publisher":"https:\/\/www.facebook.com\/webkul\/","article_published_time":"2024-04-02T11:50:40+00:00","article_modified_time":"2025-01-15T15:13:52+00:00","og_image":[{"url":"https:\/\/webkul.com\/blog\/wp-content\/uploads\/2024\/04\/activate-plugin-woocommerce-attribute-1-1200x318.webp","type":"","width":"","height":""}],"author":"Raushan Kumar Paswan","twitter_card":"summary_large_image","twitter_creator":"@webkul","twitter_site":"@webkul","twitter_misc":{"Written by":"Raushan Kumar Paswan","Est. reading time":"3 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/webkul.com\/blog\/create-attributes-woocommerce-programmatically\/#article","isPartOf":{"@id":"https:\/\/webkul.com\/blog\/create-attributes-woocommerce-programmatically\/"},"author":{"name":"Raushan Kumar Paswan","@id":"https:\/\/webkul.com\/blog\/#\/schema\/person\/db36277344bb56e4917bf0211aec8793"},"headline":"How To Create Attributes In WooCommerce Programmatically?","datePublished":"2024-04-02T11:50:40+00:00","dateModified":"2025-01-15T15:13:52+00:00","mainEntityOfPage":{"@id":"https:\/\/webkul.com\/blog\/create-attributes-woocommerce-programmatically\/"},"wordCount":457,"commentCount":2,"publisher":{"@id":"https:\/\/webkul.com\/blog\/#organization"},"image":{"@id":"https:\/\/webkul.com\/blog\/create-attributes-woocommerce-programmatically\/#primaryimage"},"thumbnailUrl":"https:\/\/webkul.com\/blog\/wp-content\/uploads\/2024\/04\/activate-plugin-woocommerce-attribute-1-1200x318.webp","keywords":["Attribute"],"articleSection":["WooCommerce","WordPress","Wordpress WooCommerce Salesforce Connector"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/webkul.com\/blog\/create-attributes-woocommerce-programmatically\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/webkul.com\/blog\/create-attributes-woocommerce-programmatically\/","url":"https:\/\/webkul.com\/blog\/create-attributes-woocommerce-programmatically\/","name":"Create Attributes in WooCommerce Programmatically","isPartOf":{"@id":"https:\/\/webkul.com\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/webkul.com\/blog\/create-attributes-woocommerce-programmatically\/#primaryimage"},"image":{"@id":"https:\/\/webkul.com\/blog\/create-attributes-woocommerce-programmatically\/#primaryimage"},"thumbnailUrl":"https:\/\/webkul.com\/blog\/wp-content\/uploads\/2024\/04\/activate-plugin-woocommerce-attribute-1-1200x318.webp","datePublished":"2024-04-02T11:50:40+00:00","dateModified":"2025-01-15T15:13:52+00:00","description":"Learn how to create attributes programmatically. This post covers step-by-step how to create attributes for your products with code.","breadcrumb":{"@id":"https:\/\/webkul.com\/blog\/create-attributes-woocommerce-programmatically\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/webkul.com\/blog\/create-attributes-woocommerce-programmatically\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/webkul.com\/blog\/create-attributes-woocommerce-programmatically\/#primaryimage","url":"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2024\/04\/activate-plugin-woocommerce-attribute-1.webp","contentUrl":"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2024\/04\/activate-plugin-woocommerce-attribute-1.webp","width":1353,"height":358},{"@type":"BreadcrumbList","@id":"https:\/\/webkul.com\/blog\/create-attributes-woocommerce-programmatically\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/webkul.com\/blog\/"},{"@type":"ListItem","position":2,"name":"How To Create Attributes In WooCommerce Programmatically?"}]},{"@type":"WebSite","@id":"https:\/\/webkul.com\/blog\/#website","url":"https:\/\/webkul.com\/blog\/","name":"Webkul Blog","description":"","publisher":{"@id":"https:\/\/webkul.com\/blog\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/webkul.com\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/webkul.com\/blog\/#organization","name":"WebKul Software Private Limited","url":"https:\/\/webkul.com\/blog\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/webkul.com\/blog\/#\/schema\/logo\/image\/","url":"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2021\/08\/webkul-logo-accent-sq.png","contentUrl":"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2021\/08\/webkul-logo-accent-sq.png","width":380,"height":380,"caption":"WebKul Software Private Limited"},"image":{"@id":"https:\/\/webkul.com\/blog\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/webkul\/","https:\/\/x.com\/webkul","https:\/\/www.instagram.com\/webkul\/","https:\/\/www.linkedin.com\/company\/webkul","https:\/\/www.youtube.com\/user\/webkul\/"]},{"@type":"Person","@id":"https:\/\/webkul.com\/blog\/#\/schema\/person\/db36277344bb56e4917bf0211aec8793","name":"Raushan Kumar Paswan","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/webkul.com\/blog\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/ce9851ee21ba1ce546af25d566be4dffeaa3d4f8a1be72688619265ad326a321?s=96&d=https%3A%2F%2Fcdnblog.webkul.com%2Fblog%2Fwp-content%2Fuploads%2F2019%2F10%2Fmike.png&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/ce9851ee21ba1ce546af25d566be4dffeaa3d4f8a1be72688619265ad326a321?s=96&d=https%3A%2F%2Fcdnblog.webkul.com%2Fblog%2Fwp-content%2Fuploads%2F2019%2F10%2Fmike.png&r=g","caption":"Raushan Kumar Paswan"},"description":"Raushan specializes in WordPress SaaS Development and Shipping Method services, delivering scalable solutions that streamline eCommerce operations. Expertise drives enhanced digital presence and empowers businesses to achieve sustained growth.","url":"https:\/\/webkul.com\/blog\/author\/raushankrpaswan-wp333\/"}]}},"amp_enabled":true,"_links":{"self":[{"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/posts\/390230","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/users\/505"}],"replies":[{"embeddable":true,"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/comments?post=390230"}],"version-history":[{"count":32,"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/posts\/390230\/revisions"}],"predecessor-version":[{"id":442785,"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/posts\/390230\/revisions\/442785"}],"wp:attachment":[{"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/media?parent=390230"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/categories?post=390230"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/tags?post=390230"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}