Get custom post type slug for an archive page

How do I discover the custom post type slug when I’m on an archive page? For instance if /products/ fires the archive-products.php template, how (pragmatically) do I get the post type slug? Thanks 7 To get the current post type use get_post_type(). Then ask get_post_type_object() for all the data you need, for example the slug: … Read more

Custom Post Type Archives by Year & Month?

How do you display the archives of a Custom Post Type by Year & Month? 5 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( … Read more

How to use a custom post type archive as front page?

I’d like to use a custom post type archive as a site’s front page, so that http://the_site.com/ is a custom post type archive displayed according to my archive-{post-type}.php file. Ideally I would like to alter the query using is_front_page() in my functions.php file. I tried the following, with a page called “Home” as my front … Read more

How to remove custom post type archive

I have a custom post type called “recipe” with the has_archive parameter set to true. Visiting mysite.com/recipe/ gives a basic archive list of all the recipes posted and a page title of “Recipes”. So far so good. Now I’m looking to disable that recipe archive page (but keep individual recipe links working). My first thought … Read more