1

I made four custom post types. And I can't figure out, why the fourth one is not showing up in the admin menu.

her is the code:

drx_services.php:

    add_action( 'init', 'drx_services_post_type' );
    function drx_services_post_type() {
        register_post_type( 'drx_services',
            array (
                'labels' => array (
                    'name' => __( 'Service-Angebote' ),
                    'singular_name' => __( 'Service-Angebot' )
                ),
                'taxonomies' => array ('post_tag', 'category'),
                'public' => true,
                'menu_icon' => 'dashicons-hammer',
                'has_archive' => true,
                'supports' => array ( 'title', 'editor', 'thumbnail', 'excerpt' ),
                'rewrite' => array ('slug' => 'service')
            )
        );
    }

include 'drx_srvcs_team.php';
include 'drx_srvcs_cafe.php';
include 'drx_srvcs_announcement.php';

drx_srvcs_team.php

add_action( 'init', 'drx_service_team_post_type' );
function drx_service_team_post_type() {
    register_post_type( 'drx_service_team',
        array (
            'labels' => array (
                'name'                => _x( 'Service-Team', 'Post Type General Name' ),
                'singular_name'       => _x( 'Service-Held', 'Post Type Singular Name' ),
                'menu_name'           => __( 'Service-Team'),
                'all_items'           => __( 'Das Service-Team'),
                'view_item'           => __( 'Service Held anzeigen'),
                'add_new_item'        => __( 'Service-Held hinzufügen'),
                'add_new'             => __( 'Neuer Service-Held'),
                'edit_item'           => __( 'Service-Held bearbeiten'),
                'update_item'         => __( 'Aktualisiere Service-Held'),
                'search_items'        => __( 'Service-Held suchen'),
            ),
            'taxonomies' => array ('post_tag', 'category'),
            'public' => true,
            'menu_icon' => 'dashicons-groups',
            'has_archive' => true,
            'supports' => array ( 'title', 'editor', 'thumbnail', 'excerpt' ),
            'rewrite' => array ('slug' => 'service-heroes')
        )
    );
}

drx_srvcs_cafe.php:

add_action( 'init', 'drx_service_cafe_post_type' );
function drx_service_cafe_post_type() {
    register_post_type( 'drx_service_cafe',
        array (
            'labels' => array (
                'name'                => _x( 'Repair Cafés', 'Post Type General Name' ),
                'singular_name'       => _x( 'Repair Café', 'Post Type Singular Name' ),
                'menu_name'           => __( 'Cafés'),
                'all_items'           => __( 'Alle Cafés'),
                'view_item'           => __( 'Café anzeigen'),
                'add_new_item'        => __( 'Café hinzufügen'),
                'add_new'             => __( 'Neues Café'),
                'edit_item'           => __( 'Café bearbeiten'),
                'update_item'         => __( 'Aktualisiere Café'),
                'search_items'        => __( 'Café suchen'),
            ),
            'taxonomies' => array ('post_tag', 'category'),
            'public' => true,
            'menu_icon' => 'dashicons-admin-multisite',
            'has_archive' => true,
            'supports' => array ( 'title', 'editor', 'thumbnail', 'excerpt' ),
            'rewrite' => array ('slug' => 'service-heroes')
        )
    );
}

drx_srvcs_announcement.php -> THIS is not showing!!

add_action( 'init', 'drx_srvcs_announcement_post_type' );
function drx_srvcs_announcement_post_type() {
    register_post_type( 'drx_srvcs_announcement',
        array (
            'labels' => array (
                'name'                => _x( 'Termine', 'Post Type General Name' ),
                'singular_name'       => _x( 'Termin', 'Post Type Singular Name' ),
                'menu_name'           => __( 'TERMINE'),
                'all_items'           => __( 'Alle Termine'),
                'view_item'           => __( 'Termin anzeigen'),
                'add_new_item'        => __( 'Termin hinzufügen'),
                'add_new'             => __( 'Neuer Termin'),
                'edit_item'           => __( 'Termin bearbeiten'),
                'update_item'         => __( 'Aktualisiere Termin'),
                'search_items'        => __( 'Termin suchen'),
            ),
            'taxonomies' => array ('post_tag', 'category'),
            'public' => true,
            'menu_icon' => 'dashicons-calendar',
            'has_archive' => true,
            'supports' => array ( 'title', 'editor', 'thumbnail', 'excerpt' ),
            'rewrite' => array ('slug' => 'termine')
        )
    );
}

The question: why is the fourth custom post type not showing up, how can I fix this?

1

Finally I found it. I was sure WP_DEBUG in wp-config.php was set to true, but it wasn't. So after changing this I got a message saying that 20 characters is maximum for a post type name.

[Sun Apr 08 18:29:44.083267 2018] [:error] [pid 5901] [client 127.0.0.1:45860] PHP Notice: register_post_type wurde fehlerhaft aufgerufen. Der Name eines Inhaltstyps muss aus mindestens einem und maximal 20 Zeichen bestehen. Weitere Informationen: Debugging in WordPress (engl.) (Diese Meldung wurde in Version 4.2.0 hinzugef\xc3\xbcgt.) in /var/www/rpc/wp-includes/functions.php on line 4147, referer: http://rpc.lkl/wp-admin/plugins.php?plugin_status=all&paged=1&s

I chose a shorter name, and now it shows up!

|improve this answer|||||

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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