[英]How do I remove all Wordpress Posts from appearing in my Custom Post Type admin screen?
这是我的代码,用于生成自定义帖子类型。
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条目。 您可以在此处看到我的意思的屏幕截图。 这些帖子实际上都不是Feature_Post,但仍显示在自定义帖子类型管理屏幕中。
我已经浏览了自定义帖子类型的法典页面,似乎没有任何与我的问题有关的内容。
我是否在$ args数组中缺少某些内容,这些内容限制了管理屏幕将显示的帖子类型?
在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';
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.