最新消息:Welcome to the puzzle paradise for programmers! Here, a well-designed puzzle awaits you. From code logic puzzles to algorithmic challenges, each level is closely centered on the programmer's expertise and skills. Whether you're a novice programmer or an experienced tech guru, you'll find your own challenges on this site. In the process of solving puzzles, you can not only exercise your thinking skills, but also deepen your understanding and application of programming knowledge. Come to start this puzzle journey full of wisdom and challenges, with many programmers to compete with each other and show your programming wisdom! Translated with DeepL.com (free version)

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

matteradmin4PV0评论
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

Post a comment

comment list (0)

  1. No comments so far