Forums

Add description to custom post type column (2 posts)

  1. Christine
    Moderator
    Posted 5 months ago #

    Hi there,
    I've got a CPT for my testimonial and I can see all of the titles in the admin but I would also like to display the description.

    I'm using the following code in my functions.php file, but can't get it to work.

    http://pastebin.com/Zw5MBPKr

    Can someone look at this and suggest a different approach?

  2. Christine
    Moderator
    Posted 5 months ago #

    Got it, I went back to this article and came up with these two functions:

    add_action("manage_posts_custom_column",  "testimonial_custom_columns");
    add_filter("manage_edit-testimonial_columns", "testimonial_edit_columns");
    
    function testimonial_edit_columns($columns){
    	$columns = array(
    		"cb" => "<input type=\"checkbox\" />",
    		"title" => "Portfolio Title",
    		"description" => "Description",
    		);
    	return $columns;
    }
    function testimonial_custom_columns($column){
    	global $post;
    	switch ($column) {
    	case "description":
    	the_excerpt();
    	break;
    
    	}
    }

Reply

You must log in to post.

About this Topic