Skip to content

Instantly share code, notes, and snippets.

@rveitch
Created August 5, 2015 02:33
Show Gist options
  • Select an option

  • Save rveitch/fa41158dfc33e0c37c2a to your computer and use it in GitHub Desktop.

Select an option

Save rveitch/fa41158dfc33e0c37c2a to your computer and use it in GitHub Desktop.
Programmatically Insert WordPress Post Categories
<?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