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
wp_insert_term(
'Custom Category',
'category',
array('slug' => 'custom-category')
);
}
Read here for more info: https://developer.wordpress.org/reference/hooks/after_setup_theme/
Related Posts:
- WP 3.4 – what action/hook is called when theme customisation is saved?
- Add a dropdown to theme customizer
- Editing the custom background CSS
- What is the problem if I use CDN in my WordPress parent theme(built using bootstrap)?
- What, specifically, should be included in theme_name_setup()?
- How to get gallery images?
- Is it possible to use line break in theme description?
- Is the theme customizer slowing down my site?
- What does “Do not deregister the jquery script in the administration area” mean?
- What is the best book to learn how to make themes for wordpress?
- Grab the first paragraph of each post
- Symlink a directory to wp-content/themes
- How to check if post has any tag?
- What are WooCommerce starter themes? [closed]
- How do I “unhook” / de-register jQuery so that it’s not called as part of wp_footer();?
- How to disable the gradient and font size internal CSS added by WordPress when using theme.json
- Is there an error in get_the_tag_list()?
- Which is the simplest theme for WordPress to use it as your base?
- “Cheatin’ uh?” error message on multple theme directories
- Adding WordPress colorpicker in widget settings
- A theme that follows all the best practices to learn from?
- How do I display the “Archives” widget layout (sidebar) in WordPress by ‘year’ then by ‘months’?
- get_post() function returns post even if it is trashed
- How to highlight the current page in the nav menu?
- How do you protect a premium theme from being copied?
- “Display Site Title and Tagline” checkbox not working?
- Add social icons in a theme through custom admin menu
- file_get_contents Not allowed in Themes?
- How can one update a theme on a live site without interruption?
- Sub folder CSS that’s read by Admin panel
- How do I remove twentyten without ruining what I did?
- Custom theme not visible in Appearance
- Some doubts about how to show posts in a custom theme?
- Dequeue a style file which is making website load slow!
- Can’t delete theme
- Developing WordPress Theme using CSS framework like Bootstrap
- WP_Customize_Color_Control omitting # symbol
- Theme translation not applying
- How to add filter the post thumbnail before save in database?
- WP_Comment_Query – Get comments and answers separately
- excerpt() shows different result between remote and localhost(development environment)
- Prefix best practice, should we use framework name or theme name?
- Theme Javascript.php Overwritten Nightly [closed]
- Where am I doing wrong in my theme menu?
- How to add Space between sidebar and footer widget in WordPress theme [closed]
- How can my theme allow users to take advantage of advanced html tags in posts
- Customizer – loading settings/controls/sections/panels based on a id/page id
- Admin: sub menu doesnt display under apperance when activate my themes
- Does code in function.php differ from theme to theme
- Create a child theme from multiple themes
- Theme not showing up
- Change image size depending on page
- Are seven additional image sizes are too many?
- How can I use the WordPress Loop and Pagination in multiple instances but different scenarios throughout my site?
- registering a global template wordpress 6.0
- Copying the theme style files and images to duplicate the website but with a difference
- Why still output /wp-content/themes/twentynineteen?
- I have WordPress setup on primary domain, how do I set it up on its subdomain using the same database?
- How to set Post meta-box defaults based on the choices made by user in Customizer?
- Theme Action to hook for one time only function [duplicate]
- How do I include a partial from a directory below a wordpress theme directory?
- Some doubts about WordPress handle the horizontal main menu visualization
- How to remove permalinks links presents in each page of my site?
- first excerpt fine, subsequent post excerpts shift to the right instead of displaying vertically [closed]
- HTTP Error when uploading images over specific dimensions
- Why is the `if else` not working?
- showing all recent posts in theme
- Is there a way to serve different resolution images to different devices?
- iPad WordPress theme?
- custom Background not showing after upgrade?
- Rolling your own WordPress Themes
- How to make a function occurs for one time?
- List categories of a post hierarchically?
- How do I restructure the comment HTML layout?
- PHP Parse error: syntax error, unexpected ‘endwhile’ (T_ENDWHILE), expecting elseif (T_ELSEIF) or else (T_ELSE) or endif (T_ENDIF) on line 124
- How to display home page last modified date in anywhere of wordpress theme?
- Is there a way to create sections under “Colors” panel in the Theme Customizer?
- Is a multipurpose theme an alternative to modifying or creating a theme from scratch?
- WooCommerce – edit templates
- WordPress Custom font not found
- How to dowload and edit content of a website
- WordPress Blog Page displaying nothing
- Best strategy for providing theme options using customizer
- Next post in category
- Magnific Popup – Add Caption to Images
- Why do WordPress developers use so many opening and closing PHP tags when developing themes? [duplicate]
- Safe way to echo wp_trim_words
- Trouble creating custom sanitization function when uploading video files
- How can I demonstrate themes well?
- What’s the policy for building a theme that doesn’t support widgets/menus?
- How Does One Create a Global Variable Repository
- How to update my own theme?
- WordPress custom jquery not found
- Any Cool WordPress Theme Editor? [closed]
- How to remove proudly created by WordPress in theme?
- getting id of page
- Roll my own theme or customize an existing one [closed]
- Is there any open source WordPress Themes?
- How to automatically set a Template Page Name next to a page in menu screen such as WooCommerce pages, front page, or posts page in wordpress?
- WP Update Messages get cut off during Theme update