{"id":47777,"date":"2010-08-11T08:00:00","date_gmt":"2010-08-11T08:00:00","guid":{"rendered":"https:\/\/www.weixiaoduo.com\/plugins\/2024\/02\/22\/custom-post-type-template-redirect\/"},"modified":"2010-08-11T22:34:00","modified_gmt":"2010-08-11T22:34:00","slug":"custom-post-type-template-redirect","status":"publish","type":"post","link":"https:\/\/www.weixiaoduo.com\/plugins\/custom-post-type-template-redirect\/","title":{"rendered":"Custom Post Type Template Redirect"},"content":{"rendered":"<p>One of the shortcomings of Custom Post Types in WordPress is that there\u2019s no way to easily set a different custom template from the standard single.php.  If it\u2019s a custom post type, it\u2019s got custom information, and I want to put it in a custom template!<\/p>\n<p>So I threw together a plugin to handle this.  With this plugin installed and activated, it checks your template directory for posttype.php then t_posttype.php.  If neither exists, then the standard WP template rules take effect.<\/p>\n<p>For example, if your custom post type is \u2018books\u2019, it\u2019s going to check your template directory for \u2018books.php\u2019.  If it finds it, it will use that as the template for your \u2018books\u2019 posts.  If not, it will check for \u2018t_books.php\u2019, and use that as the template for your \u2018books\u2019 posts.  If it finds neither, the standard WP logic kicks into place, looking to see if you\u2019ve defined a template for the post, and, if not, using single.php.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>For custom post types, allows you to have default templates specific to each custom post type.<\/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 Template Redirect - \u8587\u6653\u6735\u63d2\u4ef6\u76ee\u5f55","description":"For custom post types, allows you to have default templates specific to each custom post type."},"footnotes":""},"categories":[1],"tags":[744,156,628,768],"class_list":["post-47777","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-uncategorized","tag-custom-post-types","tag-redirect","tag-template","tag-theme"],"_links":{"self":[{"href":"https:\/\/www.weixiaoduo.com\/plugins\/wp-json\/wp\/v2\/posts\/47777","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=47777"}],"version-history":[{"count":0,"href":"https:\/\/www.weixiaoduo.com\/plugins\/wp-json\/wp\/v2\/posts\/47777\/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=47777"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.weixiaoduo.com\/plugins\/wp-json\/wp\/v2\/categories?post=47777"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.weixiaoduo.com\/plugins\/wp-json\/wp\/v2\/tags?post=47777"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}