Created
February 13, 2018 21:03
-
-
Save WPprodigy/f70ff7ebf62fbfdf873ffedd6ca139d1 to your computer and use it in GitHub Desktop.
Change default product category.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
add_action( 'init', 'wc_ninja_update_default_category_once' ); | |
function wc_ninja_update_default_category_once() { | |
// 20 = new default category ID | |
update_option( 'default_product_cat', '20' ); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
WooCommerce 3.3.2 will have a way to set a different category as the default. Until then, here's a quick workaround.
Add this PHP snippet to your site, perhaps use the Code Snippets plugin mentioned here:
https://calebburks.com/correctly-add-custom-code-woocommerce/
Replace '20' with the category ID that you want to become the new default category.
Refresh the page, then delete this snippet. (only needs to run once)
If you want, you can then delete the previous default / "uncategorized" category.