I have written code for a custom post type. The custom post type is loosely based on the cpt-bootstrap-carousel plugin, but only as far as functionality goes.
My code makes use of the manage_$post_type_posts_custom_column action and the manage_$post_type_posts_columns filter. In the function I am passing to the manage_$post_type_posts_custom_column
action, I am calling the following filter:
add_filter( 'the_title', 'my_prefix_alter_post_title_to_image_title' );
The function my_prefix_alter_post_title_to_image_title
gets the title which has been set for an attachment like this (not the whole function for brevity's sake):
function my_prefix_alter_post_title_to_image_title( $title, $post_id ) {
$meta = get_post_custom( $post_id );
$url = reset( $meta['url'] );
/* code to retrieve image title as set in the media library */
return $title;
}
I am getting this information via the url of an image which is stored in a custom meta field in the post.
I have removed the title
value from the supports
argument passed into the register_post_type
function, so the user has no way of entering a title for the custom post type.
Now comes the peculiar part: This all works as expected. When visiting the edit page for my post type, all current posts are listed with the columns I have designated. The funny thing is that the first row in the table which is used to display the posts behaves differently than all other entries.
The string 'Auto Draft' is displayed in the title column for the first entry, all other entries display the correct value (the title of the attachment as specified in the media library). Now my first assumption was, that this is due to a wrongly set priority in my add_filter
call, but even if I set that priority to 1, it has no influence on this behaviour.
Do you know the root of this problem? How can this be solved?