Is possible to create some default categories when a custom theme is activated? I mean, when I activate a custom theme, I want that some predefined category are created, for example news or info, this because using this way I can load the post directly on the template parts of the theme. Otherwise, if I want to add a custom widget plugin, how I can achieve this? I see many website that are using widgets in footer or in other part of the pages, but I've never used them so I don't know thhe correct way to add this feature on my page or post php files that have this structure:


if( have_posts() ): while( have_posts() ): the_post();





All the markup are added using shortcodes except for the title or sometimes for the post thumbnail.

1 Answer 1


You can use the after_setup_theme for this eg:

add_action( 'after_setup_theme', 'custom_add_cat' );

function custom_add_cat() {
    //Create Custom Category
    'Custom Category', 
    array('slug' => 'custom-category')

Read here for more info: https://developer.wordpress.org/reference/hooks/after_setup_theme/

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.