Define hooks
use PostTypes\PostType;
use WP_Post;
class Books extends PostType
{
//...
/**
* Adds additional hooks for the post type.
*
* @return void
*/
public function hooks(): void
{
add_action( 'save_post_book', [ $this, 'onSave' ], 10, 3 );
}
/**
* Run additional logic when saving a Books post.
*
* @param int $post_id
* @param WP_Post $post
* @param bool $update
* @return void
*/
public function onSave(int $post_id, WP_Post $post, bool $update)
{
// Run additional logic when a Books post type is saved...
}
}Last updated