As Pages are a special built in Posttype, they get an own template hierarchy. Other “normal” post types and custom post types can only be templated by “single-$posttype.php”. You can however hook into the single_template filter and make wordpress redirect to your template file:
function get_custom_post_type_template($single_template) {
global $post;
if ($post->post_type == 'account') {
$located = locate_template( 'account-'.$post->post_name.'.php' );
if ( !empty( $located ) ) {
return $located;
}
}
return $single_template;
}
add_filter( 'single_template', 'get_custom_post_type_template' );
I didn’t test this, but it should work ^^
Happy Coding,
Kuchenundkakao
Related Posts:
- What does this PHP function code mean? [closed]
- Restrict custom post type to only site administrator role
- Linking Two Post Types
- How to force one column layout on custom post type edit page?
- previous_post_link() and next_post_link() with a custom post type?
- Setting a custom sub-path for blog without using pages?
- modify all posts of a category to “no comments allowed”
- Why is the »_builtin« parameter not advised in »register_post_type()« for custom post types?
- Showing current taxonomy terms
- automatically create taxonomy with same name as post title
- Assigning a role to a specific custom post type (and ignoring other post types)
- Display posts in random post types
- Custom Post Type by user
- saving custom post type data to different table in wordpress
- Query post types with multiple keys
- [Plugin: Posts 2 Posts] Changing display order of connections
- same archive template for different custom post
- Get all posts WHERE custom_field is LIKE value
- Get the post children count of a post
- How to delete all posts from a custom post type?
- Check Title Unique Or Not and If not error message and dont save
- Remove All, Published and Trashed Post Views in Custom Post Type
- How to post twitter like updates on wordpress
- Show Two custom Post type and their posts on category page
- Trying to edit the single page from a Custom Post
- apply filters only to specific post listing without check the url parameters
- Custom post type and body_class: Remove “blog” class
- Deleting Custom Post type data using mySQL command
- Is there a way to have the view link on manage posts page to open in a new window or tab?
- Display only one post each WEEK
- List custom taxonomy specific to one custom post type
- Meta query for custom post type ignored in main query
- 2 Templates 1 custom post type according url
- Show titles, date of all posts on single category page
- Update postmeta Parent when post_status child change
- Allow users to create posts without logging in?
- Migrating a taxonomy’s tags to the native category
- How to sort posts in a custom post type by title in ascending order by default?
- Creating separate feeds for custom post types
- Get_the_terms restrict output
- Custom post type menu
- YOAST SEO won’t work on custom post type archive [closed]
- Separate Content from gallery (custom post type)
- How to get the current category with custom posts
- WordPress Count posts within a custom post type
- Template code to split a post and print a custom field?
- Displaying a list of Contacts
- Custom post type tags not showing in search
- How set template for “custom post type” individual post
- Why is my custom post content only viewable when signed into WordPress?
- Post template with breadcrumb needs to show page navigated from
- Post template not applying on theme (potentially rendering as Page template)
- Custom post type defaults to index.php for archive page
- Adding specific custom fields (images) to post excerpt
- Assign for all post of a post type a specific single-post template
- Limit posts per page depending on the size of a div?
- Delete Post by User
- creating a custom post template
- Problem to get the link of the default ‘post’ post type like the orther custom types
- Custom post type with two templates
- One Post with different content, depending on a Page
- Custom Post Type
- Why isn’t my custom post type using the corresponding custom post template?
- Search page for custom post type
- Display all post types together
- Turn post into simple slideshow
- Specifying Default Template for Hierarchal Custom Post Type [duplicate]
- Query multiple post of which one by taxonomy
- Apply text based styling done for a single post in WPBakery to all posts / create a template out of it [closed]
- How to delete unnecessary custom post types in the UI
- How to create a job post by email parsing? [closed]
- show posts under custom post type with same autj
- How to automate the creation of advanced layout article/post
- display posts, pages and custom post types from another wordpress site
- is therer any wordpress function to retrieve a specific html element from post content
- How to develop Knowledge center in WordPress Website
- Get the ID of the latest post
- Change permalinks for posts but not for custom post types
- Front end post editing using a form
- Assign single template to multiple custom post types?
- Custom taxonomy query for a custom post type
- Assign Page Template Within A Custom Post Type
- Error after deleting Custom Post Type with a function (no trash used)
- Help with CPT template pagination
- Custom Post Type | Fatal Error on register_post_type()
- Dynamically add / duplicate custom meta in custom post types
- Post image in WordPress not appearing on home page
- How to handle paged param in post and custom-post-type?
- How can I use archive-{post_type}.php theme template?
- Query within a foreach within a query (queryception)
- How to implement a different permalink structure for custom post type?
- Related “custom post type” using “custom taxonomy”
- How to have multiple search result pages in wordpress with taxonomy terms listed
- How to limit the number of custom posts certain users can publish in WordPress using php script?
- In the admin, how can you list thumbnails instead of titles for a custom post type?
- Single taxonomy for different custom post types
- Having some trouble properly displaying Custom Post Types in templates
- Make title field multiline in the add new custom post page?
- Using predefined html in new posts
- Error 403 when posting comments to a custom post type from a different page