Custom Post Types UI

December 28th, 2010

When WordPress 3.0 was launched it included a very useful new option, custom post types. WordPress has several post types built in, but the ones you and I use most often are "pages," for static content, and "posts," for blog posts and similar content. Custom post types allow you to create additional types specific to your needs.

Coventry Merchants Menu
Coventry Merchants menu

For example, on the Coventry Village Web site, I needed to add pages for each of the stores, restaurants and other merchants in the village. Originally I wanted to use posts, rather than pages, for these so that I could use categories and tags to organize them. Alas, I was concerned about the merchant categories overlapping with blog categories, especially given that the blog has multiple authors. I then thought of adding a separate blog to handle these posts, but that had its downsides as well. And then I remembered reading about custom post types. This turned out to be the perfect solution.

To make the new pages, I created a custom post type of "merchants" then added two custom taxonomies, one for merchant types such as Stores or Restaurants, and another for more descriptive tags. I could have used regular tags, but again, I wanted to keep these separate from the blog tags.

To add custom post types and taxonomies requires a bit of tinkering with your functions.php and other files. This didn't sound too complicated, but as I was reading the various instructions, I came across the Custom Post Types UI plug-in. I decided to give this a try because it would add both the post types and the taxonomies I needed. Installation was quick and easy. After a post type has been added it appears as another posting option in the left dashboard menu along with your regular pages and posts.

I quickly set to work adding my new pages and within a few weeks I was done. (There were 62 pages to build and I was working on other projects as well.) Everything looked right, and the taxonomy scheme made it really easy to browse the stores. I was now ready to add this section to the public menu and announce it on Twitter and Facebook, just as soon as I validated my pages and ran them by a few people.

Oh noes! 404 errors for custom post types: Role Scoper saves the day.

When I tried validating my pages I kept getting an error message saying the W3C couldn't validate the page because it was getting a 404 error. This left me so bewildered that after much Googling I posted a question about it on the Custom Post Type UI support forum. Then I asked my friend Jenn to look at the pages on her computer. She couldn't see them, but was getting a 404 error as well. I'd had no problem because I was logged in. Sigh. More Googling.

Then I found the problem. When you add a custom post type you are able to also assign specific capabilities such as who can edit, or view the pages. From what I'd seen the default should have been the same as for blog posts, but it wasn't. My next step was to find instructions on adding the right capabilities so that readers could view the pages. In the process I discovered that the Role Scoper plug-in could handle this for me. I'd already installed Role Scoper in order to give bloggers different privileges on the site than admins, so I just went to those settings and lo and behold, there was an option to give readers access to the merchant pages. Problem solved!

Aside from the 404 hiccup, everything went smoothly, and now that I know to use Role Scoper in conjunction with Custom Post Type UI, it will go more smoothly in the future. If you have a need for custom post types and taxonomies and don't want to be digging around in functions.php, this plug-in combo should work well for you.

Custom Post Types UI
Get Adobe Flash player This is a video about HeadSpace 2 SEO
Custom Post Type and Taxonomy Resources
Share and Enjoy:
  • Twitter
  • Facebook
  • Digg
  • StumbleUpon
  • MySpace
  • LinkedIn

Categories: WordPress Plug-ins

Tags: ,

No Comments »

No comments yet.

Leave a comment

RSS feed for comments on this post. | TrackBack URL