> For the complete documentation index, see [llms.txt](https://posttypes.jjgrainger.co.uk/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://posttypes.jjgrainger.co.uk/taxonomies/define-hooks.md).

# Define Hooks

Additional hooks are supported with the `hooks()` method.

Here you can register additional actions and filters to WordPress and allows you to keep logic associated with your taxonomy in one class.

```php
use PostTypes\Taxonomy;

class Genres extends Taxonomy
{
    //...

    /**
     * Adds additional hooks for the taxonomy.
     *
     * @return void
     */
    public function hooks(): void
    {
        add_action( 'saved_term', [ $this, 'onSave' ], 10, 5 );
    }

    /**
     * Run additional logic when saving a term.
     *
     * @param int $term_id
     * @param int $tt_id
     * @param string $taxonomy
     * @param bool $update
     * @param array $args
     * @return void
     */
    public function onSave(int $term_id, int $tt_id, string $taxonomy, bool $update, array $args)
    {
        // Check what taxonomy term we are working with...
        if ( $taxonomy !== $this->name() ) {
            return;
        }

        // Run additional logic when a term is saved...
    }
}
```
