Last active
August 22, 2021 13:35
-
-
Save cameronjonesweb/7e191bef762cb6693ae8493e512b1d13 to your computer and use it in GitHub Desktop.
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
<?php | |
/** | |
* Delete the option setting for the default category | |
* | |
* @link https://cameronjonesweb.com.au/blog/how-to-remove-the-uncategorised-category-from-wordpress-and-woocommerce | |
*/ | |
function cameronjonesweb_delete_default_category_option() { | |
if ( get_option( 'default_category' ) ) { | |
delete_option( 'default_category' ); | |
} | |
} | |
add_action( 'init', 'cameronjonesweb_delete_default_category_option' ); |
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
<?php | |
/** | |
* Remove default terms from categories | |
* | |
* @link https://cameronjonesweb.com.au/blog/how-to-remove-the-uncategorised-category-from-wordpress-and-woocommerce | |
* | |
* @param array $args Array of arguments for registering a taxonomy. | |
* @param string $taxonomy Taxonomy key. | |
* @param array $object_type Array of names of object types for the taxonomy. | |
*/ | |
function cameronjonesweb_filter_taxonomy_args( $args, $taxonomy, $object_type ) { | |
if ( 'category' === $taxonomy ) { | |
$args['default_term'] = false; | |
} | |
return $args; | |
} | |
add_filter( 'register_taxonomy_args', 'cameronjonesweb_filter_taxonomy_args', 10, 3 ); |
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
<?php | |
/** | |
* Remove default terms from categories | |
* | |
* @link https://cameronjonesweb.com.au/blog/how-to-remove-the-uncategorised-category-from-wordpress-and-woocommerce | |
* | |
* @param array $args Array of arguments for registering a taxonomy. | |
* @param string $taxonomy Taxonomy key. | |
* @param array $object_type Array of names of object types for the taxonomy. | |
*/ | |
function cameronjonesweb_filter_taxonomy_args( $args, $taxonomy, $object_type ) { | |
if ( 'category' === $taxonomy || 'product_cat' === $taxonomy ) { | |
$args['default_term'] = false; | |
} | |
return $args; | |
} | |
add_filter( 'register_taxonomy_args', 'cameronjonesweb_filter_taxonomy_args', 10, 3 ); | |
/** | |
* Delete the option setting for the default category | |
*/ | |
function cameronjonesweb_delete_default_category_option() { | |
if ( get_option( 'default_category' ) ) { | |
delete_option( 'default_category' ); | |
} | |
if ( get_option( 'default_product_cat' ) ) { | |
delete_option( 'default_product_cat' ); | |
} | |
} | |
add_action( 'init', 'cameronjonesweb_delete_default_category_option' ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment