DocumentationServices ProviderCustom Taxonomy Types

Custom Taxonomy Types

Overview

WordPress provides a powerful way to create your own taxonomy types. WP Bones provides a simple way to add your own Custom Taxonomy Types.

Create a Custom Taxonomy Type Service Provider

You may create your own Custom Taxonomy Type Service Provider by following the steps below:

php bones make:ctt MyCustomTaxonomy

By default, the new provider will be created in the plugins/CustomTaxonomyTypes directory. Of course, you may create your Service Provider manually and in any directory you prefer. You have to change the namespace accordingly.

/plugin/CustomTaxonomyTypes/MyCustomTaxonomy.php
<?php>
namespace WPKirk\CustomTaxonomyTypes;
 
use WPKirk\WPBones\Foundation\WordPressCustomTaxonomyTypeServiceProvider;
 
class MyCustomTaxonomy extends WordPressCustomTaxonomyTypeServiceProvider {
 
  protected $id     = 'wp_kirk_tax';
  protected $name   = 'Ship';
  protected $plural = 'Ships';
 
  protected $objectType = 'wp_kirk_cpt';
 
}

Load the Custom Taxonomy Type Service Provider

Add this new Service Provider to the list of providers in the /config/plugin.php file:

config/plugin.php
  /*
  |--------------------------------------------------------------------------
  | Custom Taxonomy Types
  |--------------------------------------------------------------------------
  |
  | Here is where you can register the Custom Taxonomy Types.
  |
  */
 
  'custom_taxonomies' => [ '\WPKirk\CustomTaxonomyTypes\MyCustomTaxonomy' ],