In your register post type arguments, set rewrite
to true
and has_archive
to the path you want for the archive page (without leading slash):
'rewrite' => true,
'has_archive' => 'about-us/history'
As for the redirection, rather than getting all the way to the template, you could short-circuit the loading of single posts earlier and remove the need for the single cpt template:
function wpa_parse_query( $query ){
if( is_singular() && isset( $query->query_vars['cpt_history'] ) ){
wp_redirect( home_url() );
}
}
add_action( 'parse_query', 'wpa_parse_query' );
Related Posts:
- Create a custom archive page for a custom post type in a plugin
- Custom Post Type Archive Page not showing
- Page Template as Custom Post Type Archive
- Custom post type yearly/ monthly archive permalinks
- Meta_Query as a way how to setup CPT permalinks – is it a good thing?
- Better to use a post type archive, page template, or shortcode for generating a highly configurable CPT archive?
- Is it possible to remove the posts_per_page limit on a specific post type?
- Is it possible to have an index page for taxonomy term for each custom post type it is assigned to?
- Custom post type permalink structure with the category also acting as an archive
- Rewrite custom post type url’s adding meta box values
- Hide child term posts on parent term pages
- Posts per Page on custom Taxonomy Template
- Compare 3 custom fields and sort by oldest
- Alphabetical sorting of custom post type – one letter per page
- List all posts in Custom Post Type but group dynamically by Custom Taxonomies
- Add meta data to the custom post type ARCHIVES page
- Custom post type archive sorted and grouped by date in post meta field
- Custom Post Type archive giving 404
- Custom taxonomy template not working with simple loop. Multiple CPT using the same taxonomy
- Custom-post-type-archive: posts sorted/filtered by year?
- add_rewrite_endpoint() and Custom Post Type Archive
- Custom post type archive page pagination
- Add the current menu item CSS class to a custom page type archive in WordPress menu
- Loop that displays the first post of every available custom post type?
- How do I get the permalink structure to work like this?
- How to use WP_Query in a CPT achive page?
- Have a Custom Post Type index page display taxonomy items instead of posts
- WP_Query | ‘post_type’ doesn’t work
- Editable Meta Data for Custom Post Type Archive Template
- Query var removed after rewrite
- Custom Post Type with has_archive ignores my custom archive and single template
- Custom template won’t load for a custom post type (custom permalinks used)
- Unable to get post archive link
- CPT custom archive template does not get loaded
- Custom Post Type archive loop separated by term, in specific term order
- Show only posts from one category on custom post type archive page
- How should I structure my post types?
- Extending AZIndex plugin to use custom post types and custom taxonomies
- Display custom post type category, while in a CPT category, then the posts beneath
- Number of Custom Post Types published are not being shown in the custom page
- Custom Post Type Archive URL is wrong
- How to display custom post in archive section of the wordpress page?
- Canonical url differs from custom post type archive URLs
- Custom post type archive pagination 404
- posttype/taxonomy/term archive page 404 error
- Ignoring slug capitalization on rewrite rule for custom post type archive page
- Custom Post Archive is not working
- Custom post type archive with page as parent url
- Custom post type, global categories — what’s the template name?
- Set thumbnail and title for a post type archive (not post itself!)
- Url to archive page for custom post type
- How can I use archive-{post_type}.php theme template?
- Custom meta Title for custom post type archive from page
- Return the name of the post type
- Alphabetically sort a taxonomy.php template by post title
- Custom Post type date archive for custom taxonomy
- adding custom post type “name” to single template
- Custom Post Type Archive template not being called
- Query Posts that have Custom Taxonomy
- Custom Post Type Custom Archive Page Not Working
- Getting custom taxonomy posts on archive page
- Order Custom Post Type Archive by multiple values in functions.php
- How to have multiple archive pages?
- Displaying custom taxonomy menu in custom post type archive
- WordPress sitemap with Custom Post Types
- Is possible register two archive pages for single custom post type?
- Display All Courses in Course Archive Page
- Getting Same Description in All the Custom Taxonomy Posts
- Custom Post Type / Taxonomy not displaying archive
- pagination problem listing custom post types of taxonomy in wordpress
- Static Front Page not working for custom theme
- Display Custom Post Type Archive content with Shortcode
- Permalink for custom post type pages not working
- Custom Post Type archive page listing a 404 or single post
- Set archive of custom post type like ‘posts’ page in reading settings is set
- Building Link List for Custom Tax
- Only show categories that have posts within custom post type
- get first limited words from a custom post in the archive page
- Meta_query by date for Events archive
- Customize url from the_terms
- How to Show all Values in category.php page using post_type
- Want to display my custom date archive to date.php but dont know how
- Help with Multi Level Category Archive Page
- Show index and not the archive for “Dog Custom Post” with default slug
- Custom post type archive page not showing on archive-posttype.php
- Display custom post type archive on page.php template
- Making a archive gallery page for a custom post type which already has an archive page
- Custom taxonomy in custom post type archive with pagination
- why custom post archive gives always no more than 10 posts despite of paging settings?
- Pagination fault in custom post type archive page [duplicate]
- Templates list in “Page Attributes” metabox is inaccurate
- Stop Custom post type from being searched via URL
- Permalink of custom post type partly broken
- title tag for custom post type remove taxonomy name from title tag
- How can I retrieve the slug for a custom post type via name?
- Custom taxonomy archive page not routing?
- Pagination not working for archive
- Add a class to a menu item depending on a body class
- Pagination not working only on Archive-Name.php using new WP_Query
- Can’t add custom post type archive page to menu