WordPress allows you to create your own custom content types. These content types are called 自定义帖子类型. You can use them to add custom content like products, reviews, recipes, etc. In this article, we will share the 12 most useful WordPress custom post types tutorials.
1.什么时候需要自定义帖子类型 （1. When Do You Need A Custom Post Type）
Before you start creating custom post types or taxonomies on your WordPress site, it’s important to evaluate your needs. A lot of times you can achieve the same results with the default WordPress 帖子和页面.
WordPress uses font icons in the admin area to ensure they look beautiful on all devices and screen sizes. The easiest way to add a font icon to your custom post type is by using the CPT 自定义图标 plugin. Simply install and activate the plugin and visit the plugin’s settings page to add an icon.
Replace example.com with your own domain name and products with your custom post type name. If you cannot see your custom post type, then visit 设置 » 固定链接 and click on the save changes button. This will update your permalink structure, and you should now be able to see your custom post type archive page.
4.自定义帖子类型的RSS提要 （4. RSS Feeds for Custom Post Types）
WordPress comes with a built-in RSS generator for all content types, taxonomies, authors, and date based archives. It uses a proper URL structure that queries the database and generates the RSS feed you want to see.
6.搜索表单以查找自定义帖子类型 （6. Search Form for Custom Post Types）
The default WordPress search feature is very limited. Specially if you are using custom post types on your WordPress site. You can add a 自定义 Google 搜索表单 to your WordPress site, but even that form doesn’t allow users to select search parameters.
默认的WordPress搜索功能非常有限。 特别是如果您在WordPress网站上使用自定义帖子类型。 您可以将自定义 Google 搜索表单添加到WordPress网站，但是即使该表单也不允许用户选择搜索参数。
Another solution is to use a plugin like 搜索WP which allows you to create advanced search forms and is capable of searching through all custom post types, taxonomies, and custom fields.
If you would rather prefer to build your own 自定义搜索表单, then here is what you need to do. First add your custom post types hidden fields in the search form by adding this code in searchform.php file of your child theme.
8.在自定义帖子类型上禁用Disqus （8. Disable Disqus on Custom Post Types）
If you are using WordPress 中的 Disqus 评论系统, then you will notice that your Disqus comment box will start appearing on all your custom post types. If you do not want users to comment on these custom post types, then you will need to manually disable Disqus for selective post types. Simply add this code snippet into your theme’s functions.php file or a site-specific plugin.
Now create a new form, and you will notice that there will be an option to map each field to your custom post types. For more detailed instructions see our tutorial on how to add 用户在 WordPress 中提交了自定义帖子类型的内容.
12.帖子类型的自定义元框 （12. Custom Meta Boxes for Post Types）
Custom meta boxes allow you to add custom fields into WordPress post editor screen. This way you can create additional input fields for your post types. The easiest way to create custom meta fields in WordPress is by using the 高级自定义字段 plugin.
After installing the plugin, simply click on 自定义字段 in WordPress admin bar and then click on Add New. Follow on screen instructions to create a group of custom fields you want to add to your custom post type.