Skip to content

britco/wp-default-terms

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

30 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

wp-default-terms

Circle CI

A way to set default terms for taxonomies. Similar how to the "default category" functionality works, but for any taxonomy.

Installation

composer require britco/wp-default-terms

Usage

function custom_tax_init() {
  register_taxonomy('custom-tax', array('post'), array(
    'defaults' => array(
        'Foo'
      )
  ));
}

You can also specify different defaults for different post types

function custom_tax_init() {
  register_taxonomy('custom-tax', array('post', 'custom_post_type'), array(
    'defaults' => array(
        'post' => array(
          'Foo'
        ),
        'custom_post_type' => array(
          'Bar'
        )
      )
  ));
}

Also, you can set defaults for already registered taxonomies

$taxonomy = get_taxonomy('post_tag');
$taxonomy->defaults->set(array('paper'));

License

Available under the MIT License.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Packages

No packages published