0

dashboard edit.php for custom-post-type

So I just made a Custom Post Type which doesn't need titles for it's entries.

How can I modify the posts-list in dashboard (see image) so that it would display the post's excerpt/content instead of the usual title?

1 Answer 1

1

You could edit the columns for your CPT like so:

function edit_cpt_columns($columns){
    $columns = array(
        'cb'        =>  '<input type="checkbox" />',
        'title'     =>  __('Post')
    );

    return $columns;
}
add_filter('manage_edit-CPT_columns', 'edit_cpt_columns');

function manage_cpt_columns( $column, $post_id ) {
    global $post;

    switch( $column ) {
        case 'title' :
            $link = get_permalink($post->ID);
            echo '<a href="'.$link'">'.$post->post_excerpt.'</a>';
                break;
        default :
                break;
    }
}
add_action( 'manage_CPT_posts_custom_column', 'manage_cpt_columns', 10, 2);

You would need to replace CPT with the name of your custom post type.

The first function declares you columns while the 2nd function fills the columns with data.

Your Answer

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

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