Yes, you can.
All you need is make a filter for wp_get_archives();
so it accepts post_type
parameter:
function my_custom_post_type_archive_where($where,$args){
$post_type = isset($args['post_type']) ? $args['post_type'] : 'post';
$where = "WHERE post_type="$post_type" AND post_status="publish"";
return $where;
}
then call this:
add_filter( 'getarchives_where','my_custom_post_type_archive_where',10,2);
Whenever you want to display archive by custom post type, just pass the post_type args:
$args = array(
'post_type' => 'your_custom_post_type',
'type' => 'monthly',
'echo' => 0
);
echo '<ul>'.wp_get_archives($args).'</ul>';
Related Posts:
- get the custom post type title/name
- Want to display my custom date archive to date.php but dont know how
- 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
- Date archives for custom post type
- Better to use a post type archive, page template, or shortcode for generating a highly configurable CPT archive?
- Display all custom post types in archives.php
- 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
- just can’t get date-based archives per post-type to work
- CPT Archive with core Category
- Changing number of posts per page on CPT-archive.php, have tried 20-30 code chunks so far
- 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?
- How to filter by date & a specific custom post type post-WP 4.4?
- 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
- Set post date before 1970
- Permalink Structure for Multiple Post Type Archives by Taxonomy
- Custom post type yearly/ monthly archive permalinks
- How to show more posts on an archive page?
- Hide child term posts on parent term pages
- Compare 3 custom fields and sort by oldest
- Removing CPT slug from URL results in 404 error for archive page
- Multiple post types in archives (filter?)
- Alphabetical sorting of custom post type – one letter per page
- List all posts in Custom Post Type but group dynamically by Custom Taxonomies
- Custom Post Type archive giving 404
- Add the current menu item CSS class to a custom page type archive in WordPress menu
- Query var removed after rewrite
- Custom post types archive redirect
- Custom Post Type with has_archive ignores my custom archive and single template
- How to get post type and month/year before while loop for date.php file
- Set thumbnail and title for a post type archive (not post itself!)
- Archive links for custom post types
- Show All Custom Post Types On A Single Archive Page
- Query Posts that have Custom Taxonomy
- WordPress giving a 404 page when passing a year argument different than the current year
- How to know which archive page is active
- Order Custom Post Type Archive by multiple values in functions.php
- 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
- Permalink for custom post type pages not working
- Set archive of custom post type like ‘posts’ page in reading settings is set
- Customize url from the_terms
- Help with Multi Level Category Archive Page
- Display custom post type archive on page.php template
- Pagination fault in custom post type archive page [duplicate]
- Permalink of custom post type partly broken
- ‘Blog Archive’ suddenly appeared on custom post type; how to remove
- Custom taxonomy archive page not routing?
- Stop header code from showing in category page?
- Pagination not working only on Archive-Name.php using new WP_Query
- Is it possible to specify a time interval (from, to) in ACF with date picker, or other custom field?