5

I have a site with some custom post types, one of which doesn't have a title.

When viewed in the admin section, the posts are listed like so

Which is less than ideal, for obvious reasons.

I have edited one of the admin files wp-admin/includes/class-wp-posts-list-table.php to display the list as below

The problem is the customisation is overwritten by upgrades.

What is the correct way to make customisations to the admin files so they survive upgrades?

2 Answers 2

14

Don't edit core WP files.

Use the provided filters instead. For instance, have a look at the manage_$posttype_posts_columns filter.

1
  • You'll get a badge for "most upvotes in shortest time" and maybe another for "most upvotes for most simple answer" ;)
    – kaiser
    Jan 24, 2012 at 4:29
1

I'm assuming you are setting the Post Title via a Custom Field created for your Custom Post Type "reviews".

As a suggestion, would it not be easier to have WordPress set the value of the Post Title from the value in which you enter into your Custom Field instead of having to alter the columns of the post list?

This would avoid that ugly scenario where you see Auto Draft and would make the Post Title available should you wish to call it using <?php the_title();?> in various places within your theme.

In some instances for Custom Post Types, I have completely removed the Post Title field seen traditionally at the top of the edit screen. Instead I've replaced the usual fields seen with a Custom Metabox whereby one of the particular fields within this Metabox also sets the title of the post.

Coincidentally one of the ways to achieve this has also been provided by Chip Bennett above in another question located here: Custom Post Type: Set post_title equal to a custom post type field

Chip's first answer above is entirely correct in terms of the context in which this question applies. I am just providing an alternate solution opposed to traveling down that particular route in the first place.

Of course that method is perfectly usable in situations where you might want to display certain custom fields within the post columns that fall outside of the traditional, Title, Author, Date, etc already provided natively by WordPress.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.