If you’re adding a custom query within the template to load posts, the post type of that page doesn’t have to be your custom post type. You can create a plain vanilla page
, create a template for that via page-your_page_slug.php
, or via a custom template assigned in the templates dropdown, then query for whatever post type you want via WP_Query
.
EDIT – here’s an example using the single_template
filter. you’ll have to change the post type and slug to match yours.
function wpa_single_cpt_template( $templates="" ){
$single = get_queried_object();
if( 'myCPT' == $single->post_type
&& 'my-special-slug' == $single->post_name )
$templates = locate_template( 'my-special-template.php', false );
return $templates;
}
add_filter( 'single_template', 'wpa_single_cpt_template' );
adapted from the example on Template Hierarchy: Filter Hierarchy.
Related Posts:
- Page Template as Custom Post Type Archive
- Custom Post Type – Archive page title
- How to make an archive page displaying posts in a date range
- Editable content on a Custom Archive page
- Custom Page that comes with preloaded content for the user
- Adding the_content() in custom template email
- Custom URL redirect in WP
- How to integrate single and archive templates for custom post type in any WordPress theme
- How to get the current category with custom posts
- WordPress Page hierarchy ( parent is singular of custom post types slug ) is returning not found
- Displaying posts inside table having issues
- Building Link List for Custom Tax
- Show index and not the archive for “Dog Custom Post” with default slug
- Templates list in “Page Attributes” metabox is inaccurate
- Custom Post Type Archives by Year & Month?
- Custom Post Type Template – Archive
- Prevent pre_get_posts filter on specific post type
- Setting a custom sub-path for blog without using pages?
- How to change “Draft” string for status of custom post type to “Unavailable”?
- How to Remove Certain Screen Options and Table Columns from post type in wp_list_table?
- How to List All Custom Post Types Names (Not Posts)
- How does one delete orphan custom post type?
- What are the advantages of using a custom post type archive?
- Add a Template to a custom post type
- WordPress calls archive page instead of Custom Page Template
- Localization For Two Different Regions/Domains with the Same Language
- Showing current taxonomy terms
- I can’t set meta_key in my custom post type query
- White screen error for a custom theme
- automatically create taxonomy with same name as post title
- How can I remove categories in menu in custom post type?
- Archive page for taxonomy of custom post type
- Search results ordered by custom post types are not grouped
- saving custom post type data to different table in wordpress
- Remove POST_TYPE from custom post type permalink
- Create Custom Post Type Archive Page with Sub Categories Navigation Sidebar
- Display Posts of a Category in Alphabetical Order (Custom Post Type)
- Get all posts WHERE custom_field is LIKE value
- Custom query variable – get wordpress to redirect to nice permalink url
- Multiple portfolios with one custom post type?
- Including Custom Post Type posts in a page template contextually (or should I widget?)
- Add custom post type archives to search results?
- Second Custom Post Type Archive
- is_main_query() not working for WP REST API
- Delete link on single-custom.php with redirection
- Custom Post Type – List all attachments on Edit Screen
- Creating a Page to View the List of Posts for a Custom Post Type?
- How to customize a permalink (URL) structure?
- Is it possible to create relational metabox values in a custom post?
- Custom Post Type Query for Sidebar Doesn’t Work on Front Page
- Single post with a Custom Post Type returns 404, when archives of the CPT work correctly
- Update postmeta Parent when post_status child change
- Custom post type archive page blank
- Custom Post Type slug same as page name
- How to Get WordPress custom post data in WooCommerce product meta panel? [closed]
- Show Custom Post Type meta boxes only on Page Edit
- Creating a Page Template to display all items from a Custom Post Type
- Filter widget outputs
- Send notification to the admin when new custom post is submitted
- don’t publish custom post type post if a meta data field isn’t valid
- Detect inside a custom query the kind of post type to assign custom classes
- How do you make a custom post type items automatically delete items 3 months after publication?
- Associate page w/ specific single post template?
- Add an Outside Wrapper to my Header and Make it Full Width
- Custom page for editing custom post type on frontend based on url
- How to Create a Separate Page for Blog Posts in WordPress
- Add custom columns in custom post type browse page
- How do I display child post types in the parent post type template
- Removed custom post type archive page shows blog page
- Custom permalink structure for remote content pages
- cannot achieve this structure (custom posts VS categories VS ??)
- Why doesnt my tag page populate with this custom post type?
- Home page is getting current-menu-item even if it’s not home
- How to set a ‘page’ as parent of a custom post type?
- How to use pre_get_posts on archive page custom post type
- How to change Elementor Template for Single Page Post on Load
- A certain theme is forcing it’s singular post layout
- How to change URL for custom post type archive?
- Stored meta from attachment, video length?
- Custom post type option page template
- Custom post Query and WordPress Post Query Clash
- How can I find out what template is my custom post type using?
- Search custom post type result in same template page
- How do I make my archive page look like popular reviewing sites (e.g., Polygon and Gamespot) [closed]
- Static front page has page url not site url
- Remove the “View” Link in Post edit Admin
- Get data from custom post type to another custom post type?
- Using get_terms() as shortcode attribute
- Multiple Block Quotes without using HTML
- Taxonomy Query of Custom Post Displays Archive Instead of Posts
- How can i display on front page a movie that is atached in a post type
- Custom post type functions.php if statement on action
- Set a Custom Post Type as a Homepage
- Slideshow/Gallery plugin based on WP Core Gallery [closed]
- Custom Post Types using wrong template (index) instead of archive-{type}.php – previously worked as expected
- Show custom post type on post category page doesn’t work / breaks navigation
- On archive.php show loop for child categories if they exist or posts if they don’t, on custom post type
- How to automate the creation of advanced layout article/post
- Sort CPT by taxonomy AND THEN by custom field
- I want to show a list of posts under specified categories