Manually Adding Admin Columns to Custom Post Type
-
I am using your plugin to get feedback from a custom post type, and I am having trouble adding the ratings columns to the admin table for the post type, as it doesn’t seem to just show up automatically (maybe because I am already adding custom tables to it?).
The custom post type is registered and then I am adding custom columns with the following:
// Custom admin columns for post type function edit_columns($columns){ $columns = array( 'cb' => '<input type="checkbox" />', 'title' => 'Question', 'content' => 'Answer', 'taxonomy-faq_cat' => 'Category' ); return $columns; } add_filter('manage_faq_posts_columns', __NAMESPACE__ . '\edit_columns');
I tried to add the ratings columns manually with the follow:
// Custom admin columns for post type function edit_columns($columns){ global $post; $upvotes = thumbs_rating_show_up_votes($post->ID); $downvotes = thumbs_rating_show_down_votes($post->ID); $columns = array( 'cb' => '<input type="checkbox" />', 'title' => 'Question', 'content' => 'Answer', 'taxonomy-faq_cat' => 'Category', $upvotes = 'Upvotes', $downvotes = 'Downvotes', ); return $columns; } add_filter('manage_faq_posts_columns', __NAMESPACE__ . '\edit_columns');
But it had a weird effect: it shows the upvotes count + the content of the post, and leaves the downvotes blank: https://d.pr/i/qZLC
As well, if you look at the screen options for the post type in the admin, it shows the Downvotes as an option, but not the Upvotes… https://d.pr/i/6fnvAny thoughts here?
Thanks!
Matt
- The topic ‘Manually Adding Admin Columns to Custom Post Type’ is closed to new replies.