britco/wp-default-terms

Installs: 64

Dependents: 0

Suggesters: 0

Security: 0

Stars: 0

Watchers: 8

Forks: 0

Open Issues: 1

Type:wordpress-plugin

v0.1.6 2015-09-29 02:22 UTC

This package is not auto-updated.

Last update: 2024-04-27 16:19:53 UTC


README

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.