robiulroky 发表于 2024-1-31 05:35:12

The easiest way to add new custom post types

This would create a post type named “product” that’s identified as “acme_product.” The register_post_type function gets two values. The first one being “labels” for the name. The second one is “public” to make it show up on the admin screen and on your site. And lastly “has_archive” to enable the new post type’s archive.

After setting this up, you should see the menu entry for the custom post type, be able to add posts, view Country Email List the post list in the admin, and visit them on your website. There are many more values, or arguments, you can add to a custom page. A full list of them can be found on the register post type page of the Codex.

Next, create a 16×16 pixel icon image and save it to your current plugin folder. This is required for the custom post type icon in the dashboard. Another option is to use a font icon. If you’d be interested ingoing that route we have a quick guide for how to use Dashicons for your custom post types that you should read. Then you can go on and activate the plugin.

http://zh-cn.boleads.com/wp-content/uploads/2024/01/habib11.j.jpg

A note on naming: while it’s tempting and convenient to use a simple custom post type identifier it’s better to prefix. Use a short namespace that identifies the plugin, theme, or website that uses the custom type. For a much more detailed guide, checkout the tuts+ guide to WordPress Custom Post Types. They dig into more code and custom post type options if you want to code your post types yourself. But if you want a quicker and easier option, keep reading.

页: [1]
查看完整版本: The easiest way to add new custom post types