So, I asked this question differently in another thread but it was more of an advice type question so it really didn’t render any useful responses. I believe I can word it better and should help some of you decipher what I am trying to accomplish and possibly help someone else once we collaborate on a solution.
I have a custom post type that is using very limited Supports (described here) values because I only need the meta-box values for my custom post type. It doesn’t make sense for my type to include a title and content. Code below:
register_post_type( 'athlete',
array(
'labels' => array(
'name' => 'Athletes',
'singular_name' => 'Athlete',
'add_new' => 'Add New',
'add_new_item' => 'Add New Athlete',
'edit' => 'Edit',
'edit_item' => 'Edit Athlete',
'new_item' => 'New Athlete',
'view' => 'View',
'view_item' => 'View Athlete',
'search_items' => 'Search Athletes',
'not_found' => 'No Athletes found',
'not_found_in_trash' => 'No Athletes found in Trash',
'parent' => 'Parent Athlete'
),
'public' => true,
'menu_position' => 15,
'supports' => array( 'thumbnail' ),
'taxonomies' => array( '' ),
'has_archive' => true
)
);
As you can see, I only need the thumbnail supports option because the rest of my post type will be meta-boxes (not including in this question). The problem is, when I save an Athlete, I have two problems, I do not know how to display my meta-box values in the Athlete list (as columns in the grid) and I do not know how to set the Title value as it always sets it to “Auto-Generated” which is not preferred. If the Title will be a field that is searchable, I would prefer to set the value to [First Name]+[Last Name]. Can anyone help with these two issues and explain if I am going to run into any problems by using a custom post type as opposed to using custom database tables and a custom UI to manage my object?
I’ve dabbled in this as well. For a meta box I recommend the Meta Box plugin (which I regularly contribute code to). A good tutorial on how to use it is here. For custom columns, do a search in WPSE but this should get you started. Saving the post title involves using the
save_post
filter. When you set up your meta box, remember the id you used for the first and last names and replace then in the code below: