Warning: include_once(/home4/aquapan/public_html/cjbarnaby/wp-content/plugins/wp-super-cache/wp-cache-phase1.php): failed to open stream: No such file or directory in /home/revela25/public_html/cjbarnaby/wp-content/advanced-cache.php on line 22
Warning: include_once(): Failed opening '/home4/aquapan/public_html/cjbarnaby/wp-content/plugins/wp-super-cache/wp-cache-phase1.php' for inclusion (include_path='.:/opt/cpanel/ea-php74/root/usr/share/pear') in /home/revela25/public_html/cjbarnaby/wp-content/advanced-cache.php on line 22
Warning: include(/home4/aquapan/public_html/cjbarnaby/wp-content/plugins/wp-super-cache/wp-cache-base.php): failed to open stream: No such file or directory in /home/revela25/public_html/cjbarnaby/wp-content/plugins/wp-super-cache/wp-cache.php on line 137
Warning: include(): Failed opening '/home4/aquapan/public_html/cjbarnaby/wp-content/plugins/wp-super-cache/wp-cache-base.php' for inclusion (include_path='.:/opt/cpanel/ea-php74/root/usr/share/pear') in /home/revela25/public_html/cjbarnaby/wp-content/plugins/wp-super-cache/wp-cache.php on line 137
Warning: include_once(/home4/aquapan/public_html/cjbarnaby/wp-content/plugins/wp-super-cache/ossdl-cdn.php): failed to open stream: No such file or directory in /home/revela25/public_html/cjbarnaby/wp-content/plugins/wp-super-cache/wp-cache.php on line 174
Warning: include_once(): Failed opening '/home4/aquapan/public_html/cjbarnaby/wp-content/plugins/wp-super-cache/ossdl-cdn.php' for inclusion (include_path='.:/opt/cpanel/ea-php74/root/usr/share/pear') in /home/revela25/public_html/cjbarnaby/wp-content/plugins/wp-super-cache/wp-cache.php on line 174
Warning: Cannot modify header information - headers already sent by (output started at /home/revela25/public_html/cjbarnaby/wp-content/advanced-cache.php:22) in /home/revela25/public_html/cjbarnaby/wp-includes/rest-api/class-wp-rest-server.php on line 1893
Warning: Cannot modify header information - headers already sent by (output started at /home/revela25/public_html/cjbarnaby/wp-content/advanced-cache.php:22) in /home/revela25/public_html/cjbarnaby/wp-includes/rest-api/class-wp-rest-server.php on line 1893
Warning: Cannot modify header information - headers already sent by (output started at /home/revela25/public_html/cjbarnaby/wp-content/advanced-cache.php:22) in /home/revela25/public_html/cjbarnaby/wp-includes/rest-api/class-wp-rest-server.php on line 1893
Warning: Cannot modify header information - headers already sent by (output started at /home/revela25/public_html/cjbarnaby/wp-content/advanced-cache.php:22) in /home/revela25/public_html/cjbarnaby/wp-includes/rest-api/class-wp-rest-server.php on line 1893
Warning: Cannot modify header information - headers already sent by (output started at /home/revela25/public_html/cjbarnaby/wp-content/advanced-cache.php:22) in /home/revela25/public_html/cjbarnaby/wp-includes/rest-api/class-wp-rest-server.php on line 1893
Warning: Cannot modify header information - headers already sent by (output started at /home/revela25/public_html/cjbarnaby/wp-content/advanced-cache.php:22) in /home/revela25/public_html/cjbarnaby/wp-includes/rest-api/class-wp-rest-server.php on line 1893
Warning: Cannot modify header information - headers already sent by (output started at /home/revela25/public_html/cjbarnaby/wp-content/advanced-cache.php:22) in /home/revela25/public_html/cjbarnaby/wp-includes/rest-api/class-wp-rest-server.php on line 1893
Warning: Cannot modify header information - headers already sent by (output started at /home/revela25/public_html/cjbarnaby/wp-content/advanced-cache.php:22) in /home/revela25/public_html/cjbarnaby/wp-includes/rest-api/class-wp-rest-server.php on line 1893
{"id":3991,"date":"2023-03-07T01:36:35","date_gmt":"2023-03-07T01:36:35","guid":{"rendered":"http:\/\/cjbarnaby.com\/?p=3991"},"modified":"2023-03-07T01:37:11","modified_gmt":"2023-03-07T01:37:11","slug":"copy-post-categories-to-woocommerce-categories","status":"publish","type":"post","link":"http:\/\/cjbarnaby.com\/copy-post-categories-to-woocommerce-categories\/","title":{"rendered":"Copy Post Categories To Woocommerce Categories"},"content":{"rendered":"\t\t
\n\t\t\t\t\t\t\n\t\t\t\t\t\t
\n\t\t\t\t\t
\n\t\t\t
\n\t\t\t\t\t\t
\n\t\t\t\t
\n\t\t\t\t\t\t\t\t\tThis was a time saver thanks to AI helper.\r\n\r\nUse at your own risk.\r\n\r\n \t\t\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t
\n\t\t\t\t
\n\t\t\t\t\t\t\t
\n\t\t\t
\n\t\t\t\t\n\t\t\t\t\t\n\n\/\/ category post to product copy specific id's\n\nfunction copy_specific_post_categories_to_product_categories() {\n $args = array(\n 'taxonomy' => 'category',\n 'orderby' => 'name',\n 'order' => 'ASC',\n 'hide_empty' => false,\n 'include' => array(76,77,78,79,80,81,82,83,87,88,89,90,91,91,92,93,94,95) \/\/ Add the category IDs you want to copy here\n );\n\n $post_categories = get_categories($args);\n\n foreach ($post_categories as $post_category) {\n $parent_id = $post_category->parent;\n $cat_args = array(\n 'name' => $post_category->name,\n 'description' => $post_category->description,\n 'slug' => $post_category->slug,\n 'parent' => 0,\n );\n $cat_id = wp_insert_term($post_category->name, 'product_cat', $cat_args);\n\n if (!is_wp_error($cat_id)) {\n if ($parent_id > 0) {\n $parent_term = get_term_by('id', $parent_id, 'product_cat');\n if ($parent_term) {\n wp_update_term($cat_id['term_id'], 'product_cat', array('parent' => $parent_term->term_id));\n }\n }\n }\n }\n}\n\nadd_action( 'init', 'copy_specific_post_categories_to_product_categories' );\n\/\/\n\n<\/xmp>\n\t\t\t\t<\/code>\n\t\t\t<\/pre>\n\t\t<\/div>\n\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t<\/section>\n\t\t\t\t<\/div>\n\t\t","protected":false},"excerpt":{"rendered":"
This was a time saver thanks to AI helper. Use at your own risk. \/\/ category post to product copy specific id’s function copy_specific_post_categories_to_product_categories() { $args = array( ‘taxonomy’ => ‘category’, ‘orderby’ => ‘name’, ‘order’ => ‘ASC’, ‘hide_empty’ => false, ‘include’ => array(76,77,78,79,80,81,82,83,87,88,89,90,91,91,92,93,94,95) \/\/ Add the category IDs you want to copy here ); […]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-3991","post","type-post","status-publish","format-standard","hentry","category-attachments"],"yoast_head":"\n
Copy Post Categories To Woocommerce Categories - cjbarnaby<\/title>\n\n\n\n\n\n\n\n\n\n\n\n\n\n\t\n\t\n\t\n