这是我生成自定义帖子类型的代码。
add_action( 'init', 'feature_post_type' );
function feature_post_type() {
$labels = array(
'name' => 'Feature Posts',
'single_name' => 'Feature Post',
'add_new' => 'Add New',
'add_new_item' => 'Add New Feature Post',
'edit' => 'Edit',
'edit_item' => 'Edit Feature Post',
'new_item' => 'New Feature Post',
'view' => 'View',
'view_item' => 'View Feature Post',
'search_items' => 'Search Feature Posts',
'not_found' => 'No Features found',
'not_found_in_trash' => 'No Features found in Trash',
);
$args = array(
'labels' => $labels,
'public' => true,
'rewrite' => array('slug' => 'feature'),
'menu_postion' => 5,
'has_archive' => true,
'hierarchical' => true,
'taxonomies' => array('category', 'post_tag'),
'can_export' => true,
'supports' => array( 'title', 'author', 'editor', 'comments', 'thumbnail', 'custom-fields', 'excerpt')
);
register_post_type( 'feature_posts ', $args );
}
帖子类型的管理员屏幕虽然列出了wordpress数据库中的所有帖子,但它应该只显示feature_posts条目。你可以看到我的意思here的截图。这些帖子实际上都不是Feature_Posts,但仍然出现在自定义帖子类型管理界面中。
我已经浏览了自定义帖子类型的codex页面,似乎没有任何与我的问题相关的内容。
我的$ args数组中是否遗漏了限制管理界面显示的帖子类型的内容?
答案 0 :(得分:0)
在sql中使用以下查询。
DELETE relations.*, taxes.*, terms.*
FROM wp_term_relationships AS relations
INNER JOIN wp_term_taxonomy AS taxes
ON relations.term_taxonomy_id=taxes.term_taxonomy_id
INNER JOIN wp_terms AS terms
ON taxes.term_id=terms.term_id
WHERE object_id IN (SELECT ID FROM wp_posts WHERE post_type='custom-fields');
DELETE FROM wp_postmeta WHERE post_id IN (SELECT ID FROM wp_posts WHERE post_type = 'custom-fields');
DELETE FROM wp_posts WHERE post_type = 'custom-fields';