1

I've created a simple custom post type. In my wordpress site, permalinks are set to Post Name.

In the admin screen for posts of my custom post type, no permalink editor is displayed.

How do I make this show up, as it does normally for the default post types?

This is how I've created the definition:

function register_cpt_staff_member() {

    $labels = array(
        'name' => __( 'staff', 'staff-member' ),
        'singular_name' => __( 'staff-member', 'staff-member' ),
        'add_new' => __( 'Add New', 'Staff Member' ),
        'add_new_item' => __( 'Add New Staff Member', 'staff_member' ),
        'edit_item' => __( 'Edit Staff Member', 'staff_member' ),
        'new_item' => __( 'New Staff Member', 'staff_member' ),
        'view_item' => __( 'View Staff Member', 'staff_member' ),
        'search_items' => __( 'Search Staff Members', 'staff_member' ),
        'not_found' => __( 'No results found', 'staff_member' ),
        'not_found_in_trash' => __( 'No staff found in Trash', 'staff_member' ),
        'parent_item_colon' => __( 'Parent Staff Member:', 'staff_member' ),
        'menu_name' => __( 'Staff', 'Staff_member' ),
    );

    $args = array(
        'labels' => $labels,
        'hierarchical' => false,
        'supports' => array( 'title', 'editor', 'thumbnail', 'custom-fields' ),
        'public' => false,
        'show_ui' => true,
        'show_in_menu' => true,
        'menu_position' => 5,
        'show_in_nav_menus' => false,
        'publicly_queryable' => true,
        'exclude_from_search' => true,
        'has_archive' => false,
        'query_var' => true,
        'can_export' => true,
        'rewrite' => true,
        'capability_type' => 'post'
    );

    register_post_type( 'staff_member', $args );
}
  • Share the code you are using for creating post type – BlueSuiter Apr 28 '17 at 8:26
  • Have you resaved your permalinks page to flush the permalinks. (This solves these problems 99% of the time!) – mayersdesign Apr 28 '17 at 8:31
  • @AmitChauhan: I've updated the post to show my definition. – bob Apr 28 '17 at 8:35
  • @mayerdesign: Yes. Every time I've altered the code I've flushed permalinks. – bob Apr 28 '17 at 8:35
  • maybe the permalink editor is linked to "public => TRUE" – mmm Apr 28 '17 at 8:49
2

Your CPT is not public, therefor the "posts" of that type have no reason to have a public URL (AKA permalink), therefor wordpress do not bother to add the permalink (actually slug) UI.

-1
function testimonials_custome_post(){
    $labels = array(
            'name' => __('Testimonials', 'testimonials'),
            'singular_name' => __('Testimonials', 'testimonials'),
            'add_new' => __('New Testimonials', 'testimonials'),
            'add_new_item' => __('Add new Testimonials', 'testimonials'),
            'edit_item' => __('Edit Testimonials', 'testimonials'),
            'new_item' => __('New Testimonials', 'testimonials'),
            'view_item' => __('View Testimonials', 'testimonials'),
            'search_item' => __('Search Testimonials', 'testimonials'),
            'not_found' => __('No The Testimonials Found', 'testimonials'),
            'not_found_in_trash' => __('No The Testimonials found in trash', 'testimonials')
        );
    $args = array(
            'labels' => $labels,
            'public' => true,
            'menu_icon' => 'dashicons-pressthis',
            'supports' => array(
                    'title',
                    'editor',
                ),
        );

    register_post_type('testimonials', $args);
}

add_action('init', 'testimonials_custome_post' ); 

WORKING CODE FOR CUSTOM POST

  • 2
    Please explain how this answers the question. – Milo Apr 28 '17 at 13:00

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.