You will need to write a custom rewrite rule for this.
Just copy the following code into your functions.php and flush rewrite rules.
function xlinkerz_custom_archive_rewrite_rule( $rewrite_rules ) {
$custom_slug = 'custom_archive';
$year_rule = array( $custom_slug . '/([0-9]{4})/([0-9]{1,2})/?$' => 'index.php?year=$matches[1]&monthnum=$matches[2]' );
$month_rule = array( $custom_slug . '/([0-9]{4})/?$' => 'index.php?year=$matches[1]' );
// Merging rules
$rewrite_rules = $year_archive + $month_archive + $rewrite_rules;
return $rewrite_rules;
}
add_filter('rewrite_rules_array', 'xlinkerz_custom_archive_rewrite_rule');
*Flushing rewrite rules can be done in several ways, the easiest way is to go to the admin area and just save the permalinks. Remember you should not be calling flush_rewrite_rules(); within a function which defines new rewrite rules.
Related Posts:
- Custom Post Type Archives by Year & Month?
- Get custom post type slug for an archive page
- Meta_Query as a way how to setup CPT permalinks – is it a good thing?
- Proper way of making custom post type landing page or archive page
- Custom Post Type Archives by Date with Custom Permalink
- Change title in head on Archive page
- Custom Post Type Archives with 0 Posts Redirects as 404
- Page is defaulting to archive page and not designated template
- Better to use a post type archive, page template, or shortcode for generating a highly configurable CPT archive?
- paginate function in archive for custom-post-type
- Custom post type archive sorted and grouped by date in post meta field
- How to create archive page for taxonomy terms within custom post type
- How to make an archive page displaying posts in a date range
- WordPress custom post type archive with description
- Custom-post-type-archive: posts sorted/filtered by year?
- How to list custom post types?
- Custom post type archive page pagination
- Editable content on a Custom Archive page
- Second Custom Post Type Archive
- is_main_query() not working for WP REST API
- CPT Archive with core Category
- Changing number of posts per page on CPT-archive.php, have tried 20-30 code chunks so far
- get the custom post type title/name
- URL of a custom post type’s post format archive?
- Create template for taxonomy results limited by Custom Post Type
- Custom post type archive page blank
- How to display custom post in archive section of the wordpress page?
- What’s the name of the custom post type yearly archive template?
- How can I use archive-{post_type}.php theme template?
- Return the name of the post type
- Use the custom post type archive for taxonomies?
- Archive page for custom post type and custom taxonomy
- Why does my URL keep returning 404 error code?
- How to have multiple archive pages?
- Create a Custom Path to Archive
- Custom Post Type Date Based Archive URL rewrite [duplicate]
- WordPress sitemap with Custom Post Types
- Is possible register two archive pages for single custom post type?
- Custom Post type page content (archive page)
- Group custom post type posts by month
- Creating an archive page or simple template to list all values of a custom field of specific post type listing
- Do not show child pages within a file page
- Tell wordpress to show a single page instead of an archive page
- Custom Post Type archive page listing a 404 or single post
- date archive future posts
- Rewriting archive page slug to be different than custom post type slug
- Site loads very slow for archive custom post type page
- Stop Custom post type from being searched via URL
- Custom post type category page not working
- paging is not working properly on news archives page [duplicate]
- How can I set up the URL for a category archive for a custom post type?
- Taxonomy Query of Custom Post Displays Archive Instead of Posts
- Generate daily archive whenever any post type is added
- Pagination not working for archive
- How to have a dynamic slug and rendering the archive-{post_type}.php?
- Remove plugin’s custom post type archive page and single pages [closed]
- WordPress CPT archive page display sticky post first and then display the rest of the posts in same Query
- Remove date rewrite rule for custom post type archive page
- Custom Post Type Archives by Date and Taxonomy
- Custom post types – Use post_id in permalink structure when using has_archive => true
- How do I display two separate taxonomy archives for two post types that share a single taxonomy?
- How to add meta box to backend menu page
- What are the advantages of using a custom post type archive?
- Custom Permalinks for Custom post Type Archives?
- is_singular won’t call my functions?
- Regex problem in an add_rewrite_rule
- Custom taxonomy archive page not working
- How to show multiple post types on taxonomy archive?
- get_categories for custom post type and filter by custom taxonomy (brand) and list child categories of a defined category
- Get the next event using date_query
- CPT: archive-cpt.php VS custom page template
- Category page only displaying the posts from a custom type
- Change name of custom post type archive
- An empty Custom Post Type Archive page returns 404 in WP 3.1
- Displaying Page as Custom Post type landing Page
- Default sort on admin columns with meta date hides draft posts with empty date value
- Filtering WP_Query
- Custom post type – get_day_link()
- CPT archive admin menu label
- Content Editable CPT Archive?
- Excluding a Custom Post Type with a specific tag using pre_get_posts
- sort CPT on Custom Taxonomy Archive page
- Display Date & Author Info on Custom Post Type Archive Page
- Custom post type archive – error in nav-menu-template.php
- Get single posts archive information
- Does this archive template part look like its making too many calls to the db?
- Set up Custom Taxonomy Archive Template File To Cover 3 Categories
- Compare ACF Date field to today or yesterday
- Custom post types not showing on the standard WordPress Category page
- Turning archive templates to a page template maintaining the slug
- Custom Post Type / Taxonomy / Term – what template to use to avoid 404-page?
- Custom Archive – hide posts until a search is made?
- How to manage a custom post type archive as a page?
- Custom Post Type shows pagination (w/404) or posts_per_page query, but not both
- group posts by month/date ignore years
- How to display custom post type ordered by a custom field date
- Have two (permalinks) urls for a same custom post type
- Is it possible to specify a time interval (from, to) in ACF with date picker, or other custom field?
- How do I get an intermediary page between 2 custom post types?
- Many CPT is conflicting of the custom date