Define Post Types

Post types can be added to a Taxonomy using the posttypes() method. This method should return an array of post type names to associate with the taxonomy.

An empty array is returned by default and no post types are attached to the Taxonomy.

use PostTypes\Taxonomy;

class Genres extends Taxonomy
{
    //...

    /**
     * Returns post types attached to the Genres taxonomy.
     *
     * @return array
     */
    public function posttypes(): array
    {
        return [
            'post',
            'books',
        ];
    }
}

This method only attaches the post type to the taxonomy, to create a post type see the documentation on creating a new post type.

Taxonomies and post types can be created and registered in any order.

Last updated