> 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/post-types/define-labels.md).

# Define Labels

Labels for a post type are defined in the `labels()` method and must return an array of labels.

By default, an empty array is returned and the WordPress default labels are used.

See [`get_post_type_labels()`](https://developer.wordpress.org/reference/functions/get_post_type_labels/) for a full list of supported labels.

```php
use PostTypes\PostType;

class Books extends PostType
{
    //...

    /**
     * Returns the Books post type labels.
     *
     * @return array
     */
    public function labels(): array
    {
        return [
            'name'               => __( 'Books', 'my-text-domain' ),
            'singular_name'      => __( 'Book', 'my-text-domain' ),
            'menu_name'          => __( 'Books', 'my-text-domain' ),
            'all_items'          => __( 'Books', 'my-text-domain' ),
            'add_new'            => __( 'Add New', 'my-text-domain' ),
            'add_new_item'       => __( 'Add New Book', 'my-text-domain' ),
            'edit_item'          => __( 'Edit Book', 'my-text-domain' ),
            'new_item'           => __( 'New Book', 'my-text-domain' ),
            'view_item'          => __( 'View Book', 'my-text-domain' ),
            'search_items'       => __( 'Search Books', 'my-text-domain' ),
            'not_found'          => __( 'No Books found', 'my-text-domain' ),
            'not_found_in_trash' => __( 'No Books found in Trash', 'my-text-domain' ),
        ];
    }
}
```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## 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, and the optional `goal` query parameter:

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

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
