{"id":47694,"date":"2010-08-26T08:00:00","date_gmt":"2010-08-26T08:00:00","guid":{"rendered":"https:\/\/www.weixiaoduo.com\/plugins\/2024\/02\/22\/custom-post-type-archives\/"},"modified":"2011-08-09T03:57:00","modified_gmt":"2011-08-09T03:57:00","slug":"custom-post-type-archives","status":"publish","type":"post","link":"https:\/\/www.weixiaoduo.com\/plugins\/custom-post-type-archives\/","title":{"rendered":"Custom Post Type Archives"},"content":{"rendered":"<p><strong>Since version 3.1 WordPress has it\u2019s own implementation of custom post type archives so you can create them without this plugin \u2013 visit this page for more info -> https:\/\/codex.wordpress.org\/Post_Types. Nevertheless I do believe that this plugin is more flexible and you can still use it and it will still work as expected.<\/strong><\/p>\n<p>This plugin will enable custom post type archives (also yearly, monthly and daily) together with feeds, customizable titles and paging.<\/p>\n<p>These archives will work the same way as the category or tag archives work when you go to, for example, http:\/\/example.com\/category\/example.<\/p>\n<p>WordPress 3.0 new custom post type feature is awesome. The only problem is \u2013 it lacks archive functionality for these post types so you can\u2019t easely assign one URL to just list your \u2018photo\u2019 post type posts. You also won\u2019t be able to get feeds just from this post type. This plugin adds this functionality to WordPress so that you can fully enjoy custom post types. It will also let you to create seperate templates for your post type archives which wasn\u2019t possible before. You will be able to use the same things you are familiar with if you are a theme developer as well as you will be able to enjoy this feature if you are not a developer but just want to enable this feature for your blog.<\/p>\n<p>With this plugin you will be able to specify:<\/p>\n<ul>\n<li>URL base for custom post types. Assuming you have a post type named \u2018photo\u2019, you can list all your post types in URL http:\/\/example.com\/photo or http:\/\/example.com\/post-type\/photo \u2013 whatever you like by simply filling one field.<\/li>\n<li>Whether to use the custom post type rewrite slug or custom post type name as URL parameter after \u2018URL base\u2019. It defaults to true, because that\u2019s the way it should work, but it might be more efficient to disable this option. For more information please read the FAQ. Also if this option is enabled then you will be able to specify a custom rewrite slug for each enabled custom post type archive.<\/li>\n<li>Title for post type archives. You can use {POST_TYPE_NAME} and {POST_TYPE_SINGULAR_NAME} variables into this option. {POST_TYPE_NAME} will be replaces with current post types name and {POST_TYPE_SINGULAR_NAME} will be replaces with current post types singular name. So if you are in post type \u2018photo\u2019 and this option is set to \u2018Post Type \u201c{POST_TYPE_SINGULAR_NAME}\u201d\u2018 then the title will say \u2018Post Type \u201cPhotos\u201d\u2018. You can also use {SEP}, {SEP_LEFT_SPACE}, {SEP_RIGHT_SPACE}, {SEP_SPACED}. These will be replaced with seperator specified in wp_title function. Spaced ones will have the space on defined side. {SEP_LEFT_SPACE} will have space in left side and vice verca. {SEP_SPACED} will have spaced on both sides. I had to do this in this way, because WordPress trims variables before saving. If left blank (this option), plugin won\u2019t change the title. You can also specify a custom title for each enabled custom post type archive.<\/li>\n<li>What template file to use for rendering a custom post type. You can use either one template for all post types or just type \u2018post-type-{POST_TYPE}.php\u2019 and for post type \u2018photo\u2019 plugin will try to include \u2018post-type-photo.php\u2019 to render the custom post type.<\/li>\n<li>What template file to load if above template file is not found. So it\u2019s easy to use index.php for all post types except \u2018photo\u2019 for example.<\/li>\n<li>Whether to add a feed link for custom post type archive. Will work the same way as any other feed links, for example in category index pages where your visitors can subscribe to your site updates. Plugin will automatically insert the feed link if <a href=\"https:\/\/codex.wordpress.org\/Function_Reference\/add_theme_support\" rel=\"nofollow ugc\">\u2018automatic-feed-links\u2019<\/a> is enabled for your theme. If that\u2019s true then plugin won\u2019t show this option in plugin settings.<\/li>\n<li>Post types that gets archives. Just tick the checkboxes next to those post types you want to see archives. Easy as that.<\/li>\n<\/ul>\n<p>Note that if you update URL base field, disable\/enable post type rewrite tag usage or enable\/disable some post type archives, then you will have to visit \u2018Permalinks\u2019 section under \u2018Settings\u2019 to flush old permalinks and enable the changes.<\/p>\n<p>Also a good thing for theme developers \u2013 you have four new functions to use:<\/p>\n<ul>\n<li>pta_is_post_type_archive \u2013 this function will work similary as is_category or is_single and so on. It will return true if this page is a custom post type archive or false if it isn\u2019t. You can also specify an optional argument with post type name and then function will return boolean to say whether you\u2019re in post type archive for that post type or not. Simple and useful!<\/li>\n<li>get_the_post_type_permalink \u2013 this function will return a link to custom post type archive for current post in the WordPress loop. Or you can specify a post type slug or post ID or post object as an argument if you are not in a loop. In this way you can always link to custom post type archives wherever you are.<\/li>\n<li>the_post_type_permalink \u2013 uses get_the_post_type_permalink to echo the link rather than return it.<\/li>\n<li>wp_get_post_type_archives \u2013 will work the same way as <a href=\"https:\/\/codex.wordpress.org\/Function_Reference\/wp_get_archives\" rel=\"nofollow ugc\">\u2018wp_get_archives\u2019<\/a> function that allows you to get yearly, monthly, daily (and so on) archives for custom post types.<\/li>\n<\/ul>\n<p>If you have any issues at all, please try these steps that hopefully will help you:<\/p>\n<ul>\n<li>check out the Faq section to search for an answer for your question<\/li>\n<li>visit plugins homepage (http:\/\/ratvars.com\/custom-post-type-archives) for more information (you can also leave a comment there)<\/li>\n<li>create a new forum topic in here about the issue you\u2019re having<\/li>\n<\/ul>\n<p>I will try to help you as good as I can.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Enables custom post type archives that will support both paging and feeds. All fully customizable.<\/p>\n","protected":false},"author":65,"featured_media":229092,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"slim_seo":{"title":"Custom Post Type Archives - \u8587\u6653\u6735\u63d2\u4ef6\u76ee\u5f55","description":"Enables custom post type archives that will support both paging and feeds. All fully customizable."},"footnotes":""},"categories":[1],"tags":[644,954,744,2213,2096],"class_list":["post-47694","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-uncategorized","tag-archive","tag-custom-post-type","tag-custom-post-types","tag-post-type","tag-post-types"],"_links":{"self":[{"href":"https:\/\/www.weixiaoduo.com\/plugins\/wp-json\/wp\/v2\/posts\/47694","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.weixiaoduo.com\/plugins\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.weixiaoduo.com\/plugins\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.weixiaoduo.com\/plugins\/wp-json\/wp\/v2\/users\/65"}],"replies":[{"embeddable":true,"href":"https:\/\/www.weixiaoduo.com\/plugins\/wp-json\/wp\/v2\/comments?post=47694"}],"version-history":[{"count":0,"href":"https:\/\/www.weixiaoduo.com\/plugins\/wp-json\/wp\/v2\/posts\/47694\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.weixiaoduo.com\/plugins\/wp-json\/wp\/v2\/media\/229092"}],"wp:attachment":[{"href":"https:\/\/www.weixiaoduo.com\/plugins\/wp-json\/wp\/v2\/media?parent=47694"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.weixiaoduo.com\/plugins\/wp-json\/wp\/v2\/categories?post=47694"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.weixiaoduo.com\/plugins\/wp-json\/wp\/v2\/tags?post=47694"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}