• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar

Damien Carbery - Website Development

Getting You Online & Keeping You There

Getting You Online & Keeping You There Get Started
  • Home
  • Services
  • Maintenance Plans
  • Portfolio
  • Blog
  • About Me
  • Contact
You are here: Home / Website Development / WordPress Custom Post Types in the admin area

WordPress Custom Post Types in the admin area

Published: January 8, 2014 (Updated: October 18, 2017)

While I was proud of myself for being an early adopter of Custom Post Types when I used them on the Body Connection Spa web site, it annoyed me that I could not get custom columns to work in the admin area. This annoyed me for almost a year when I finally hunted down a solution - changing dashes to underscores in the CPT's internal name.

I began work on the Body Connection Spa website in December 2010. Just a few months earlier WordPress added support for ‘Custom Post Types‘. I used the custom post types feature for the ‘Special Offers’ on the Body Connection Spa site.

I decided to use ‘bc-special-offers‘ as the internal name for my CPT. This was great and everything worked as expected. Except one area – the admin area that listed the special offers.

As CPTs were relatively new, there weren’t many blog posts about them. I chose to use dashes instead of underscores as that is what most filenames used during my time working with GNOME when I worked at Sun Microsystems. The reasoning is that dashes are quicker to type, while underscores need the Shift key. It turned out that the dashes were the problem – none of the blog posts mentioned this!!

In my code I simply changed ‘bc-special-offers‘ to ‘bc_special_offers‘ and it all worked. I did have to make the same change in the database (post_type column in the wp_posts table) so that the existing Special Offer posts were still accessible but I was relieved to finally be able to display custom columns. I added ‘Expiry Date & Time’ and ‘Price’ columns.

Body Connection Spa Special Offers page with custom columns

I got a lot of help from these two articles:

  • Guide to WordPress’s Custom Write Panels with a few corrections by Yoast.
  • Custom Columns for custom post types (which was inspired by a post by Yoast).

Reader Interactions

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *


The reCAPTCHA verification period has expired. Please reload the page.

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Primary Sidebar

Blog Categories

  • Being Green
  • Food
  • Grammar
  • Just Strange
  • Laziness
  • Personal
  • Portfolio
  • Race Reports
  • Shudder
  • Typo
  • Website Development
  • WooCommerce Tips
  • Facebook
  • Twitter

Copyright © 2013–2023 Damien Carbery · Using Genesis Framework · Privacy Policy