Support » Fixing WordPress » Custom Post Type Not named properly in Admin after PHP update

  • Resolved Dhas

    (@dhas)


    I recently updated from PHP 5.3 to PHP 7 on our site – everything seems fine except our custom post types no longer display properly in Admin – instead of the proper names it lists as ‘Posts’ and has no image. not a huge deal but would like to resolve it. below is the code we use to register them:

    function add_post_types_charity_experience() {
    
        $pt[] = explode(',', 'news,News,News,1970,,icon-experiences.png');
        $pt[] = explode(',', 'staff,Staff,Staff,1971,,icon-experiences.png');
        $pt[] = explode(',', 'cleaning-chemistries,Brands,Brands,1972,,icon-experiences.png');
        $pt[] = explode(',', 'products,Products,Products,1973,,icon-experiences.png');
        $pt[] = explode(',', 'processes,Processes,Processes,1974,,icon-experiences.png');
        $pt[] = explode(',', 'process-care,Process Care,Process Care,1975,,icon-experiences.png');
    
        foreach($pt as &$post_type) {
            list($post_type, $nice_name, $nice_name_singular, $position, $cats, $menu_icon) = $post_type;
            $supports = explode(',', 'title,editor,thumbnail,revisions,excerpt');
            register_post_type( $post_type,
                array(
                    'menu_icon' => '/static/img/'.$menu_icon,
                    'taxonomies' => array($cats),
                    'supports' => $supports,
                    'show_in_menu' => true,
                    'menu_position' => (integer) $position,
                    'labels' => array(
                        'name' => __( $nice_name ),
                        'singular_name' => __( $nice_name_singular )
                    ),
                    'public' => true,
                    'has_archive' => true,
                    'rewrite' => array('slug' => $post_type),
                )
            );
        }
        flush_rewrite_rules();
    }
Viewing 3 replies - 1 through 3 (of 3 total)
Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Custom Post Type Not named properly in Admin after PHP update’ is closed to new replies.