Custom posts of one type have disappeared from admin. Still appear on site

Closed. This question is off-topic. It is not currently accepting answers.Questions that are too localized (such as synt

Closed. This question is off-topic. It is not currently accepting answers.

Questions that are too localized (such as syntax errors, code with restricted access, hacked sites, hosting or support issues) are not in scope. See how do I ask a good question?

Closed 6 years ago.

Improve this question

At some point this morning I realised that all of my custom posts of one type ('resources'), have disappeared from admin, the section is still there yet says 'no posts found'. Another type, 'contacts' remain. Yet my 'resources' still appear on their page as if they're in the database.

The custom fields I had created for each post type were still in the AFC admin section but were no longer linked to resources (although they were still linked to contacts).

I have tried undoing what I've done so far today but I can't seem to locate the issue! Any thoughts/suggestions on how I can retrieve them?!

I have a mu-plugin for registering my post types, maybe there's something I've missed here:

function register_post_types() {
    register_post_type('contact', array(
        'public' => true,
        'menu_icon' => 'dashicons-admin-users',
        'supports' => array(
            'title', 
            'editor', 
            'excerpt',
            'page-attributes',
            'custom-fields'),
        'labels' => array(
            'name' => 'Contacts',
            'add_new_item' => 'Add New Contact',
            'edit_item' => 'Edit Contact',
            'all_items' => 'All Contacts',
            'singular_name' => 'Contact'
        )
    ));

...

register_post_type('resources', array(
        'public' => true,
        'taxonomies'  => array(
            'category'),
        'supports' => array(
            'title', 
            'editor', 
            'excerpt',
            'page-attributes',
            'custom-fields'),
        'labels' => array(
            'name' => 'Resources',
            'add_new_item' => 'Add New Resource',
            'edit_item' => 'Edit Resource',
            'all_items' => 'All Resources',
            'singular_name' => 'Resource')
    ));
}

Thanks in advance!

Closed. This question is off-topic. It is not currently accepting answers.

Questions that are too localized (such as syntax errors, code with restricted access, hacked sites, hosting or support issues) are not in scope. See how do I ask a good question?

Closed 6 years ago.

Improve this question

At some point this morning I realised that all of my custom posts of one type ('resources'), have disappeared from admin, the section is still there yet says 'no posts found'. Another type, 'contacts' remain. Yet my 'resources' still appear on their page as if they're in the database.

The custom fields I had created for each post type were still in the AFC admin section but were no longer linked to resources (although they were still linked to contacts).

I have tried undoing what I've done so far today but I can't seem to locate the issue! Any thoughts/suggestions on how I can retrieve them?!

I have a mu-plugin for registering my post types, maybe there's something I've missed here:

function register_post_types() {
    register_post_type('contact', array(
        'public' => true,
        'menu_icon' => 'dashicons-admin-users',
        'supports' => array(
            'title', 
            'editor', 
            'excerpt',
            'page-attributes',
            'custom-fields'),
        'labels' => array(
            'name' => 'Contacts',
            'add_new_item' => 'Add New Contact',
            'edit_item' => 'Edit Contact',
            'all_items' => 'All Contacts',
            'singular_name' => 'Contact'
        )
    ));

...

register_post_type('resources', array(
        'public' => true,
        'taxonomies'  => array(
            'category'),
        'supports' => array(
            'title', 
            'editor', 
            'excerpt',
            'page-attributes',
            'custom-fields'),
        'labels' => array(
            'name' => 'Resources',
            'add_new_item' => 'Add New Resource',
            'edit_item' => 'Edit Resource',
            'all_items' => 'All Resources',
            'singular_name' => 'Resource')
    ));
}

Thanks in advance!

Share Improve this question asked Mar 27, 2019 at 12:08 JakePowellJakePowell 431 silver badge10 bronze badges
Add a comment  | 

1 Answer 1

Reset to default 1

Solved! For some reason I had changed the name of my custom post type slightly, in my register_custom_post_types.php file

register_post_type('programmes', array( 

I changed the name back and they reappeared...

I've learnt to keep in mind how changes to things can affect WP's ability to retrieve data

Edit: On further investigation it appears that the custom post type names became invalid because they were changed after the 'init' action, so stopping the virtual machine and restarting actually would have resolved the problem too

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745654760a4638477.html

相关推荐

  • Custom posts of one type have disappeared from admin. Still appear on site

    Closed. This question is off-topic. It is not currently accepting answers.Questions that are too localized (such as synt

    21天前
    50

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信