0

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!

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.