首页 文章

自定义帖子类型帖子未显示在edit.php中

提问于
浏览
1

在我的WordPress管理站点的edit.php页面中,我的自定义帖子类型帖子根本没有显示:wp-admin / edit.php?post_type = my_custom_post_type

但是,该页面在顶部显示自定义帖子类型的正确计数:

All (3) | Published (2) | Draft (1)      3 items

“添加新链接”也有效,我可以创建此类型的新自定义帖子类型,但是当我将其保存为草稿或发布时,它不会显示在列表中 . 计数值将增加,就像WordPress知道文章已发布一样,但它没有显示在edit.php列表中 .

以前有人见过这种现象吗?有谁知道可能导致这种情况发生的变化?之前工作正常 .

2 回答

  • 0

    For adding edit for your custom post type you can use ..,

    'public'=> true,

    'public_queryable'=> true,

    For removing edit for your custom post type you can use ..,

    'public'=> false,

    'public_queryable'=> false,

    这是不允许自定义帖子类型的帖子编辑页面

    register_post_type( 'address',
            array(
                'labels' => array(
                    'name' => 'Address',
                    'singular_name' => 'Address',
                    'add_new' => 'Add New',
                    'add_new_item' => 'Add New Address',
                    'edit_item' => 'Edit Address',
                    'new_item' => 'New Address',
                    'view_item' => 'View Address',
                    'search_items' => 'Search Address',
                    'not_found' =>  'Nothing Found',
                    'not_found_in_trash' => 'Nothing found in the Trash',
                    'parent_item_colon' => ''
                ),
                'public' => true,
                'publicly_queryable' => true,
                'show_ui' => true,
                'query_var' => true,
                'rewrite' => true,
                'capability_type' => 'post',
                'hierarchical' => false,
                'menu_position' => null,
                'supports' => array('title','editor','thumbnail')
            )
        );
    
  • 0

    我有同样的问题 . 在functions.php文件中有一个导致该问题的函数 . 我修改了functions.php中的主要查询,我没注意管理端的效果 . 因此,在您修改主查询的位置,您需要检查这不是管理区域使用

    !is_admin()
    

相关问题