Whilst working on a WordPress theme for a particular type of user and wanted to add a default set of terms to the custom post type that I am creating.

If this is you also then you need to use the wp_insert_term() function to achieve this.

An example. I wanted to add the term ‘Variable’ to the custom taxonomy ‘constructs’, so I use

$args = array('description' => 'my term description',
              'slug' => 'variable', 
              'parent'> 0 );
wp_insert_term( 'Variable', 'constructs', $args );

That’s all you need.

Morlene Fisher is an experienced Digital Consultant based in London, UK. She assists clients with finding the best digital solutions for their organisations and brings together many expert digital consultants to provide a service you can rely on.