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
- ACF – Tags not showing up in Custom Post Types
- A developer set a ‘standard format’ for my blogposts on wordpress but i need to remove it, how?
- Dynamically add / duplicate custom meta in custom post types
- WordPress if in term*
- How Can I Set the Post Author of a Post I Just Created With PHP?
- WordPress Orderby Numeric Value Not Working
- Setting posts per page in query_posts
- How to insert content from another Custom Post type into Post?
- Get rewrite slug of custom post type in template
- Weird problem happening with custom taxonmy when creating/updating posts
- How to show the archive / post type description on Single templates
- Exclude child pages from archive.php
- Placeholder in HTML editor text area?
- is there a way to retrieve posts that do not have a featured image assigned?
- Auto-generated posts not showing in backend (but being counted!)
- Shortcode for display posts on home page show only one post
- Find the user who initially created the post
- How can I create a custom meta box to add an mp4 video to a page?
- Need help targeting a custom post type with conditional tags
- How to get the post type from a category id?
- Plugin templates in which directory
- Delete link on single-custom.php with redirection
- Create Template for Custom Post Type same like for Page
- How to structure a site with product variations pages?