找回密码
 立即注册
搜索
热搜: 活动 交友 discuz
查看: 46|回复: 0

The easiest way to add new custom post types

[复制链接]

1

主题

0

回帖

6

积分

新手上路

积分
6
发表于 2024-1-31 05:35:12 | 显示全部楼层 |阅读模式
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.



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.

回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

Archiver|手机版|小黑屋|芝加哥华人服务中心

GMT-5, 2024-6-2 04:36 , Processed in 0.077815 second(s), 18 queries .

Powered by Discuz! X3.5

© 2001-2023 Discuz! Team.

快速回复 返回顶部 返回列表