# Use the Page Template for a Custom Post Type

> Displays single entries of chosen post types with your theme's page template instead of the blog post template, so they have no dates, authors or post navigation.

- Type: PHP
- Runs: Run everywhere
- Category: [Custom Post Types & Fields](https://wpide.com/library/category/post-types/)
- Tags: templates, themes, custom-post-types
- Author: WPIDE Team
- Installs: 0
- Updated: 2026-10-28
- Page: https://wpide.com/library/page-template-for-post-type/

## Code

```php
// Post types shown with the page template.
$wpide_page_like_types = array( 'service', 'location' );

add_filter( 'single_template_hierarchy', function ( $templates ) use ( $wpide_page_like_types ) {
    if ( ! is_singular( $wpide_page_like_types ) ) {
        return $templates;
    }

    $pos = array_search( 'single.php', $templates, true );
    array_splice( $templates, false === $pos ? count( $templates ) : $pos, 0, array( 'page.php' ) );

    return $templates;
} );
```

## Notes

Works with classic (page.php) and block themes (the "Pages" template). A single-{post_type} template still takes priority.

## How to use it

Install the free WPIDE plugin (https://wordpress.org/plugins/wpide/), find "Use the Page Template for a Custom Post Type" in its snippet library and add it in one click; or create a new PHP snippet in WPIDE (or any code snippets plugin) and paste the code above. More snippets: https://wpide.com/library/
