Created
August 5, 2015 02:33
-
-
Save rveitch/fa41158dfc33e0c37c2a to your computer and use it in GitHub Desktop.
Programmatically Insert WordPress Post Categories
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 | |
| /** | |
| * Insert a new Post Category | |
| */ | |
| function example_insert_category() { | |
| wp_insert_term( | |
| 'Example Category', | |
| 'category', | |
| array( | |
| 'description' => 'This is an example category created with wp_insert_term.', | |
| 'slug' => 'example-category' | |
| ) | |
| ); | |
| } | |
| add_action( 'after_setup_theme', 'example_insert_category' ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment