Support » Plugin: Custom Post Type UI » Post types disappeared

  • Resolved khalkjaer

    (@khalkjaer)


    I’ve been using CPT UI on a website as a way to display company profiles for a webshop, however, yesterday my post type called “companies” disappered in the admin panel, and I can’t load the pages anymore either.

    I can still find the entries in the database, so I tried recreating the post type, but now whenever I try to create a new type in the CPT UI plugin i get the following errors:

    
    Warning: array_key_exists() expects parameter 2 to be array, string given in /var/www/mediax.dk/public_html/snegult.dk/wp-content/plugins/custom-post-type-ui/inc/post-types.php on line 1880
    
    Warning: Illegal string offset 'company' in /var/www/mediax.dk/public_html/snegult.dk/wp-content/plugins/custom-post-type-ui/inc/post-types.php on line 1713
    
    Warning: Invalid argument supplied for foreach() in /var/www/mediax.dk/public_html/snegult.dk/wp-content/plugins/custom-post-type-ui/inc/utility.php on line 918
    
    Warning: Cannot modify header information - headers already sent by (output started at /var/www/mediax.dk/public_html/snegult.dk/wp-content/plugins/custom-post-type-ui/inc/post-types.php:1880) in /var/www/mediax.dk/public_html/snegult.dk/wp-includes/functions.php on line 6270
    
    Warning: Cannot modify header information - headers already sent by (output started at /var/www/mediax.dk/public_html/snegult.dk/wp-content/plugins/custom-post-type-ui/inc/post-types.php:1880) in /var/www/mediax.dk/public_html/snegult.dk/wp-admin/includes/misc.php on line 1310
    
    Warning: Cannot modify header information - headers already sent by (output started at /var/www/mediax.dk/public_html/snegult.dk/wp-content/plugins/custom-post-type-ui/inc/post-types.php:1880) in /var/www/mediax.dk/public_html/snegult.dk/wp-admin/admin-header.php on line 9
    
    Warning: session_start() [function.session-start]: Cannot start session when headers already sent in /var/www/mediax.dk/public_html/snegult.dk/wp-content/plugins/woocommerce-ajax-filters/includes/custom_post.php on line 301
    

    This functionality broke when I was installing WPML and some of the related plugins for different multilanguage functions.

    Any idea how to resolve this?

Viewing 15 replies - 1 through 15 (of 20 total)
  • You’re not the only one. After installing WPML and related plugins of WPML to make it work better I couldn’t find the CPT that had been created before.

    I can confirm getting error messages.

    Warning: array_key_exists() expects parameter 2 to be array, string given in /home/curo/domains/curo.oplevering4u.nl/public_html/wp-content/plugins/custom-post-type-ui/inc/post-types.php on line 1880
    
    Warning: Illegal string offset 'working-fields' in /home/curo/domains/curo.oplevering4u.nl/public_html/wp-content/plugins/custom-post-type-ui/inc/post-types.php on line 1713
    
    Notice: Array to string conversion in /home/curo/domains/curo.oplevering4u.nl/public_html/wp-content/plugins/custom-post-type-ui/inc/post-types.php on line 1713
    
    Warning: Invalid argument supplied for foreach() in /home/curo/domains/curo.oplevering4u.nl/public_html/wp-content/plugins/custom-post-type-ui/inc/utility.php on line 918

    Would be nice if somebody knows how to fix this.

    Plugin Author Michael Beckwith

    (@tw2113)

    The BenchPresser

    Do they come back if you deactivate WPML and the other plugins you may have activated ?

    @khalkjaer is one of your post type slugs “company” ?

    @ricardob4u is one of yours “working-fields” ?

    Regarding errors, the line about post-types.php line 1880 is from our cptui_check_existing_post_type_slugs() filter callback and apparently it’s being passed a string instead of an array. Which tells me either the saved data in our option is not structured right somehow, or we’re getting incorrectly structured data filtered in.

    That plays into the line 1713 error as well.

    Generally the same as utility.php line 918, we just don’t have an array like expected.

    SO…if either of you could confirm/deny that deactivating WPML helps out with this, that’d be awesome and provide me a confirmed good lead to run with.

    @tw2113 correct. It tried it out again to see what the problem was. Also sadly turning off WPML including the corresponding plugins does NOT solve this problem.

    When turning the plugins off it doesn’t show the CPT that has been added.
    Also I tried downgrading to older version of CPT UI to 1.7.4, but that didn’t work.

    But now thinking about it; WPML has been updated yesterday to 4.4.0
    https://wpml.org/version/wpml-4-4-0/

    Perhaps there is a issue with this version in combination with CPT UI.

    Plugin Author Michael Beckwith

    (@tw2113)

    The BenchPresser

    Didn’t see anything standing out in the 4.4.0 release log that looks like it’d apply here.

    I luckily have access to the latest WPML, and at least when simply enabling it as an active plugin, the post type I have registered is still showing up. I can add and publish as expected.

    Was it not till you did some sort of configuration of WPML that it went away, at least if you noticed really early on?

    Thread Starter khalkjaer

    (@khalkjaer)

    I’m not sure when the problem occurred during my setup, but I also installed several other wpml-related plugins for Woocommerce, Yoast and ACF support.

    Plugin Author Michael Beckwith

    (@tw2113)

    The BenchPresser

    I’ll have to dig in and see if I can manage to recreate at all.

    Thread Starter khalkjaer

    (@khalkjaer)

    For what it’s worth, I solved this issue on my website by adding the custom post types manually, forgoing the use of the CPT UI plugin. To do this I added the following code to my functions.php.

    
    // Hooking up our function to theme setup
    add_action( 'init', 'create_posttype' );
    
    /*
    * Creating a function to create our CPT
    */
     
    function custom_post_type() {
     
    // Set UI labels for Custom Post Type
        $labels = array(
            'name'                => _x( 'Companies', 'Post Type General Name', 'HelloChild' ),
            'singular_name'       => _x( 'Company', 'Post Type Singular Name', 'HelloChild' ),
            'menu_name'           => __( 'Companies', 'HelloChild' ),
            'parent_item_colon'   => __( 'Parent Company', 'HelloChild' ),
            'all_items'           => __( 'All Companies', 'HelloChild' ),
            'view_item'           => __( 'View Company', 'HelloChild' ),
            'add_new_item'        => __( 'Add New Company', 'HelloChild' ),
            'add_new'             => __( 'Add New', 'HelloChild' ),
            'edit_item'           => __( 'Edit Company', 'HelloChild' ),
            'update_item'         => __( 'Update Company', 'HelloChild' ),
            'search_items'        => __( 'Search Company', 'HelloChild' ),
            'not_found'           => __( 'Not Found', 'HelloChild' ),
            'not_found_in_trash'  => __( 'Not found in Trash', 'HelloChild' ),
        );
         
    // Set other options for Custom Post Type
         
        $args = array(
            'label'               => __( 'Companies', 'HelloChild' ),
            'description'         => __( 'Company news and reviews', 'HelloChild' ),
            'labels'              => $labels,
            // Features this CPT supports in Post Editor
            'supports'            => array( 'title', 'editor', 'excerpt', 'author', 'thumbnail', 'comments', 'revisions', 'custom-fields', ),
            // You can associate this CPT with a taxonomy or custom taxonomy. 
            'taxonomies'          => array( 'genres' ),
            /* A hierarchical CPT is like Pages and can have
            * Parent and child items. A non-hierarchical CPT
            * is like Posts.
            */ 
            'hierarchical'        => false,
            'public'              => true,
            'show_ui'             => true,
            'show_in_menu'        => true,
            'show_in_nav_menus'   => true,
            'show_in_admin_bar'   => true,
            'menu_position'       => 5,
            'can_export'          => true,
            'has_archive'         => true,
            'exclude_from_search' => false,
            'publicly_queryable'  => true,
            'capability_type'     => 'post',
            'show_in_rest' => true,
     
        );
         
        // Registering your Custom Post Type
        register_post_type( 'company', $args );
     
    }
     
    /* Hook into the 'init' action so that the function
    * Containing our post type registration is not 
    * unnecessarily executed. 
    */
     
    add_action( 'init', 'custom_post_type', 0 );
    

    Found here

    This made my original company pages show up again, and I’m pretty hesitant to tinker with turning various plugins off and on again to test things out, now that things are working as intended.

    Plugin Author Michael Beckwith

    (@tw2113)

    The BenchPresser

    Interesting that it seems to work when registering at such a high priority.

    add_action( 'init', 'custom_post_type', 0 );
    

    That 0 means run this asap, meanwhile 10 is the default.

    Plugin Author Michael Beckwith

    (@tw2113)

    The BenchPresser

    Still not managing to recreate anything here, though I know I have a bare minimum install with both CPTUI and WPML core.

    Hey Michael…so I was about to go ahead and do what @khalkjaer did and manually re-add the post-type, but I wanted to double check. The posts are still in the database and I still see the post-type in the admin cpt-ui dashboard…but I dont see the post type icon/option in admin. Not sure what happened, but it was fine until a week ago. Appreciate any help.

    Heres a screenshot of the above: https://drive.google.com/file/d/1LNoMrOGN8x0bghCH8yBsa93i2mZzqCAk/view?usp=sharing

    Plugin Author Michael Beckwith

    (@tw2113)

    The BenchPresser

    @captainmoe So the issue is that despite what you think was done properly, it’s giving you the invalid post type error?

    Yes, so the post type was there before and it was added at the same time as other post types such as staff…for example…and the others are still available. But not sure why this one…mentors…is no longer available. Not sure if this happened during the WP 5.5 update or with the latest update to CPT-UI.

    Plugin Author Michael Beckwith

    (@tw2113)

    The BenchPresser

    @captainmoe are your settings regarding things like Show UI, Show In Menu, etc still set to true? Also, just in case, did you change the capability type to something besides “post” ? If yes for that last one, unless you’re needing to adjust capabilities, it’s probably best to leave as “post”

    Plugin Author Michael Beckwith

    (@tw2113)

    The BenchPresser

    Any new changes here for anyone? @captainmoe @khalkjaer @ricardob4u

    So the issue was a 3rd party plugin was somehow making the post type inaccessible. Its not in the wp repo but I think its called Pages by User Role for WordPress.

Viewing 15 replies - 1 through 15 (of 20 total)
  • The topic ‘Post types disappeared’ is closed to new replies.