Custom Column for Title using Custom Fields
-
Hello-
I’ve built a staff directory but I’ve removed the title metabox because I use a “first name” and “last name” custom field to supply this. The problem is in my custom columns.
I can remove the title column and replace it with a combined one made out of my fields, but the nice hover over that brings up “Edit | Quick Edit | Trash | View” is gone, I’m assuming, because the title column isn’t in existence.
A side problem is that the menu editor shows these custom post types as “Auto Draft” for the title (since I never input a “real” title).
Thanks for your input.
~Kyle~
Here are the custom columns:
/*Custom Columns*/ add_filter("manage_edit-staff-directory_columns", "staff_directory_columns"); //anything can go after "manage_edit-" add_action("manage_posts_custom_column", "staff_directory_custom_columns"); //"manage_posts_custom_column" must stay as is function staff_directory_columns($columns){ $columns = array( "cb" => "<input type=\"checkbox\" />", "staff_directory_picture" => "Picture", "staff_directory_name" => "Name (<span style='font-weight: normal'>Last, First</span>)", "staff_directory_title" => "Title", "staff_directory_department" => "Department", "staff_directory_email" => "E-mail", "staff_directory_phone_number" => "Phone Number", ); return $columns; } function staff_directory_custom_columns($column){ global $post; switch ($column) { case "staff_directory_picture": echo "<img width='75px' height='75px' src='"; $key="bio_picture"; echo get_post_meta($post->ID, $key, true); echo "'/>"; break; case "staff_directory_name": echo "<a href='../wp-admin/post.php?post="; echo the_ID(); echo "&action=edit'>"; $key="name_last_name"; echo get_post_meta($post->ID, $key, true); echo ', '; $key="name_first_name"; echo get_post_meta($post->ID, $key, true); echo "</a>"; break; case "staff_directory_department": echo get_the_term_list($post->ID, 'department', '', ', ',''); break; case "staff_directory_title": $key="name_title"; echo get_post_meta($post->ID, $key, true); break; case "staff_directory_email": $key="contact_email"; echo get_post_meta($post->ID, $key, true); break; case "staff_directory_phone_number": $key="contact_phone_number"; echo get_post_meta($post->ID, $key, true); break; } }
The topic ‘Custom Column for Title using Custom Fields’ is closed to new replies.