自定义帖子类型 WordPress
我想创建一个名为推荐的自定义帖子类型,为此我希望允许管理员有机会添加公司名称/用户名以及他们给出的推荐,我知道我可以通过声明自定义帖子类型来做到这一点在我的 functions.php 文件中,但是它似乎不起作用,我得到的只是正常的帖子字段,有人可以告诉我哪里出错了,或者我该怎么做?
function testimonials_register() {
$args = array(
'label' => __('Testimonials'),
'singular_label' => __('Testimonial'),
'public' => true,
'show_ui' => true,
'capability_type' => false,
'hierarchical' => false,
'rewirte' => true,
'supports' => array('title', 'editor')
);
register_post_type('testimonial', $args);
}
I am wanting to create a custom post type called testimonials, for this I am wanting to allow the administrator that chance to add a company name/username and what testimonial they have given, I understand I can do this by declaring a custom post-type in my functions.php
file, however it does not seem to work and all I get is the normal post fields, can someone tell me where I am going wrong, or how I would do this please?
function testimonials_register() {
$args = array(
'label' => __('Testimonials'),
'singular_label' => __('Testimonial'),
'public' => true,
'show_ui' => true,
'capability_type' => false,
'hierarchical' => false,
'rewirte' => true,
'supports' => array('title', 'editor')
);
register_post_type('testimonial', $args);
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
首先,您拼写重写错误。
You spelled rewrite wrong, for starters.
您在函数之后缺少
add_action('init', 'testimonials_regiser');
。更彻底、更自定义的代码可以如下所示:
这是一个很好的 指南。
You are missing
add_action('init', 'testimonials_regiser');
afer the function.A more thorough code that's a bit more customized can be as follows:
Here is a good guide.