Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

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?

share|improve this question
add comment

2 Answers

up vote 14 down vote accepted

Don't edit core WP files.

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

share|improve this answer
    
Awesome, thanks. Worked a treat. –  LukeR Jan 23 '12 at 22:08
    
You'll get a badge for "most upvotes in shortest time" and maybe another for "most upvotes for most simple answer" ;) –  kaiser Jan 24 '12 at 4:29
add comment

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.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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