我有一个自定义的帖子类型,其中我有一个问题,它的帖子状态始终保持为发布。每当我选择status draft或pending review,然后单击update按钮。它再次将post状态显示为publish,并且不会更改。请看下面的代码,并告诉我哪里出错了。
add_action('init', 'properties_create_post_type');
function properties_create_post_type() {
$soto_property_labels = array(
'name' => __('Properties', 'custom'),
'singular_name' => __('Property', 'custom'),
'add_new' => __('Add New Property', 'custom'),
'add_new_item' => __('Add New Property', 'custom'),
'edit_item' => __('Edit Property', 'custom'),
'new_item' => __('New Property', 'custom'),
'all_items' => __('All Properties', 'custom'),
'view_item' => __('View Property', 'custom'),
'search_items' => __('Search Property', 'custom'),
'not_found' => __('No Properties found', 'custom'),
'not_found_in_trash' => __('No Properties found in Trash', 'custom'),
'parent_item_colon' => '',
'menu_name' => __('Properties', 'custom'),
);
register_post_type('soto_property',
array(
'labels' => $soto_property_labels,
'supports' => array('title'),
'public' => TRUE,
'has_archive' => TRUE,
'rewrite' => array('slug' => __('properties', 'custom')),
'menu_icon' => plugins_url('properties/assets/img/properties.png'),
'menu_position' => 42,
'categories' => array(),
)
);
}发布于 2015-03-06 00:00:45
我已经在我的网站上测试了你的代码,我没有看到任何问题,我可以将帖子状态设置为我想要的任何内容,并正确更新它。因此,您的代码没有问题,而是其他东西有问题。
在按下更新按钮的同时,开发人员工具中是否出现任何错误?您是否检查过服务器日志文件中的错误?
发布于 2015-03-06 05:15:02
你应该做的是:
单击Save Draft创建帖子,即

Save Draft菜单将消失,并显示Update按钮。然后,如果您想要更改Draft或Pending Review,请单击edit status的下拉列表。从下拉列表中选择Draft或Pending Review。单击ok,Update.Save Draft或Save as Pending按钮将出现在图像的位置(我在这里附加了红色circle).Save Draft或Save as Pending按钮。这是在发布后将任何帖子Update为Draft或Pending Review的方法。但是,如果你已经收到了,让我知道,我会发送更多的截图。
https://stackoverflow.com/questions/28663357
复制相似问题