@DarrenLee, to add multiple post types on your code, you just make a change on function cpt_rewrite_rules
. Create an array of your post types, put function cpt_generate_date_archives
inside loop.
function cpt_rewrite_rules($wp_rewrite)
{
$post_types = array( 'book', 'movie', 'etc' ); //create post_types array
$rules = array();
foreach( $post_types as $post_type )
{
/* generate date archives */
$rule = cpt_generate_date_archives( $post_type, $wp_rewrite );
foreach( $rule as $k => $v )
$rules[ $k ] = $v;
}
$wp_rewrite->rules = $rules + $wp_rewrite->rules; // combine rules
return $wp_rewrite;
}
add_action('generate_rewrite_rules', 'cpt_rewrite_rules');
Related Posts:
- Make Two Views of Post Type Archive At Two URLs
- Showing only future posts in archive based on custom field date
- How to remove current year from wp_get_archives
- Archive template
- Archive list for custom post type categories
- Check if is post type archive and in category
- Not able to see CPT archive template
- Create Archive Page with Visual Composer
- Add archive/category results to single post page
- Not able to see archive page of custom posts
- Custom Post Type archive (archive-{post-type}.php) is not working
- How to display archive page posts based on author_id
- Limiting the Archive page to posts posted by particular author
- Using WP_Query how can I show events (a custom post type) that are in the future?
- Archive-Custom-Post-Type order by Event Date, ASC, and hide events that have completed
- What code do I “comment out” to remove the loop from this Custom Taxonomy
- Group Archive list by posts tag
- Custom Post Archive – display page 1 differently then subsequent pages
- CountUp timer for custom post
- Custom Post Type Archive – archive.php is present, but it is not being used
- Custom post type archive url when post type has archive string
- get custom post archieve by month
- Customing Annual Archive plugin
- Notice- undefined variable post and trying to get property of non-object
- WordPress Rewrite Url with arugments
- How to link to an archive-special.php from a custom front-page template?
- Sort Custom Post Type Archive by Taxonomy Term [duplicate]
- Page is defaulting to archive page and not designated template
- custom post type archive page url to point to Page permalink
- Add Settings to Custom Post Type
- Custom Post Type Works but Still Shows “Page Not Found”
- Rewrite custom post type url’s adding meta box values
- I can’t set meta_key in my custom post type query
- is_post_type_archive not working in feed
- Archive page for taxonomy of custom post type
- Create Custom Post Type Archive Page with Sub Categories Navigation Sidebar
- Custom query variable – get wordpress to redirect to nice permalink url
- How do I get WordPress URL rewrites into Sitemap?
- add_rewrite_endpoint() and Custom Post Type Archive
- Add custom post type archives to search results?
- Second Custom Post Type Archive
- is_main_query() not working for WP REST API
- WP_Query | ‘post_type’ doesn’t work
- Editable Meta Data for Custom Post Type Archive Template
- Archives for Custom Post Types (without Pages)
- Set up Custom-Post-Type Author Archive
- Custom post type templating problem
- Custom Taxonomy Template Error: Catchable fatal error: Object of class WP_Error could not be converted to string
- Single post with a Custom Post Type returns 404, when archives of the CPT work correctly
- Custom post type archive page blank
- Creating a Custom Post Type
- Custom Post Type slug same as page name
- Taxonomy archive page WP_Query does not return get_the_permalink() or get_permalink() value
- Custom post type archive pagination query issue
- Use one template only for custom post type archives?
- WordPress alphabetical A-Z custom post type post result display
- How to set up Custom Post Type archive page as Front page
- Custom posts not paginating on archive page and returning 404
- Custom Post Type Query issue
- Polylang : Display term archive even if no posts
- Custom Permalinks For CPT and pages with parent. Advanced WordPress
- How to integrate single and archive templates for custom post type in any WordPress theme
- ACF for custom post type archive pages: which hook to use?
- How to display the_archive_title() and the_archive_description() – “weird” interaction
- Link from archive-page.php to single-page.php
- Custom Post Type with Configurable Sidebar via ACF
- Archive page for custom post type and custom taxonomy
- Pagination does not work on Custom Post Type archive while trying to get load more function working
- How to have multiple archive pages?
- Create a Custom Path to Archive
- WordPress sitemap with Custom Post Types
- Custom post archive page not opening 404 page
- Archive page of CPT’s custom Taxonomy
- Archive page for WordPress Custom Post Type doesn’t show pagination from paginate_links()
- Detect Ajax call inside pre_get_posts function
- Custom post type archive URLs with a single taxonomy
- Create an array with all the links of the years’ archive (of a custom post type)
- Custom post type author issues
- ACF Pro Accessing fields on a Custom Post Type
- Do not show child pages within a file page
- Custom taxonomy with custom post type archive page
- Custome post type “tags” pick default archive instead of custom post type archive
- Customize url from the_terms
- Want to display my custom date archive to date.php but dont know how
- Highlight a Post on archive page if it has a new comment?
- Display custom post type archive on page.php template
- WordPress and Raty.js
- Custom Post Type Archive Links Not Working
- CPT archive as home page
- Archive page of filtered posts
- Why is this custom post type defaulting to archive.php?
- Displaying categories items among posts
- Archive Page Pagination not working
- single-mySlug.php works: archive-mySlug.php does not. Custom Post Type
- has_archive for default post type
- URL rewrites af
- Pagination for Custom Post Type with Multiple Types
- Custom Post Type Archive Title Lowercase
- Pagination not working only on Archive-Name.php using new WP_Query
- add_rewrite_rule pagination 404 error on page 4 and above