WordPress 3.0 and the Custom Post Type

Well, enough have been said about the bunch of the new features the upcoming WordPress 3.0 carries. Custom background support, new navigation/menu settings UI and above all, the networking tool which enables you the solution to expand your WordPress installation to multi-blog version a.k.a. WordPress MU.

I was recently designing a portfolio/showcase site for our company and I fancied the new Custom Post Types function which enables you to expand the post types from post and page to as many post types as you would imagine. Say portfolio, movies, gallery, etc…

The post type I wanted to create was portfolio and I came up with the code below:

// aditional post types
function rms2_post_type_portfolio() {

register_post_type( 'folio', array(	'label' => __( 'Portfolio' ),
'singular_label' => __( 'Portfolio Item ' ),
'public' => true,
'show_ui' => true,
'supports' => array('title', 'editor', 'author', 'thumbnail', 'excerpt', 'custom-fields')

register_taxonomy_for_object_type('post_tag', 'folio');
add_action('init', 'rms2_post_type_portfolio');

The arguments and parameters supported are described here on WP Engineer. I will only add the following arguments and parameters which are not discussed on WP Engineer.

  • title: shows the title bar in theĀ  edit page. The title bar will not appear in the add new/edit page if you leave this parameter.
  • editor: enables the post editor in the add new/edit page. The editor will disappear if you leave this parameter.
  • author: enables the author meta-box so you can choose to set the post author to another user.

Also you can add 'page-attributes' parameter in the supported parameters if you want to use custom templates for your custom post type.



Tags: ,

Leave a Reply

Your email is never published nor shared. Required fields are marked *

  • You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>

Login to your Account

I forgot my password.