# 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.

```php
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](/post-types/create-a-post-type.md) on creating a new post type.

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


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://posttypes.jjgrainger.co.uk/taxonomies/define-post-types.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
