0

I've created a custom post type, as I'm making a site which will feature job listings.

I want the sidebar in the dashboard to show "Jobs" as the name.

Here is my code in functions.php

// Register Custom Post Type
        function custom_post_type() {

            $labels = array(
                'name'                => _x( 'Jobs', 'Post Type General Name', 'text_domain' ),
                'singular_name'       => _x( 'job', 'Post Type Singular Name', 'text_domain' ),
                'menu_name'           => __( 'Post Type', 'text_domain' ),
                'parent_item_colon'   => __( 'Parent Item:', 'text_domain' ),
                'all_items'           => __( 'All Jobs', 'text_domain' ),
                'view_item'           => __( 'View Job', 'text_domain' ),
                'add_new_item'        => __( 'Add New Job', 'text_domain' ),
                'add_new'             => __( 'Add New Job', 'text_domain' ),
                'edit_item'           => __( 'Edit Job', 'text_domain' ),
                'update_item'         => __( 'Update Job', 'text_domain' ),
                'search_items'        => __( 'Search Jobs', 'text_domain' ),
                'not_found'           => __( 'Not found', 'text_domain' ),
                'not_found_in_trash'  => __( 'Not found in Trash', 'text_domain' ),
            );
            $args = array(
                'label'               => __( 'custom_job', 'text_domain' ),
                'description'         => __( 'Jobs Listing', 'text_domain' ),
                'labels'              => $labels,
                'supports'            => array( ),
                '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'     => 'page',
            );
            register_post_type( 'custom_job', $args );

        }

        // Hook into the 'init' action
        add_action( 'init', 'custom_post_type', 0 );

However for some reason this shows up in WP as "Post Type" in the sidebar. But I can't see anywhere that it would be coming from... I thought the name label was the name shown in the sidebar?

Where did I go wrong?

enter image description here

1 Answer 1

1

Use this one. Notice 'menu_name' field says Jobs now.

// Register Custom Post Type
function custom_post_type() {

  $labels = array(
    'name'                => _x( 'Jobs', 'Post Type General Name', 'text_domain' ),
    'singular_name'       => _x( 'job', 'Post Type Singular Name', 'text_domain' ),
    'menu_name'           => __( 'Jobs', 'text_domain' ),
    'parent_item_colon'   => __( 'Parent Item:', 'text_domain' ),
    'all_items'           => __( 'All Jobs', 'text_domain' ),
    'view_item'           => __( 'View Job', 'text_domain' ),
    'add_new_item'        => __( 'Add New Job', 'text_domain' ),
    'add_new'             => __( 'Add New Job', 'text_domain' ),
    'edit_item'           => __( 'Edit Job', 'text_domain' ),
    'update_item'         => __( 'Update Job', 'text_domain' ),
    'search_items'        => __( 'Search Jobs', 'text_domain' ),
    'not_found'           => __( 'Not found', 'text_domain' ),
    'not_found_in_trash'  => __( 'Not found in Trash', 'text_domain' ),
  );

  $args = array(
    'label'               => __( 'custom_job', 'text_domain' ),
    'description'         => __( 'Jobs Listing', 'text_domain' ),
    'labels'              => $labels,
    'supports'            => array( ),
    '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'     => 'page',
  );

  register_post_type( 'custom_job', $args );

}

// Hook into the 'init' action
add_action( 'init', 'custom_post_type', 0 );
0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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