How to Create Content Types for Your WordPress Website

A new feature in WordPress (new as of version 3.0) is a feature called custom post types. This feature allows you, the site owner, to create different content types for your WordPress site that give you more creative control over how different types of content are entered, published, and displayed on your WordPress website.

By default, WordPress already has different post types built into the software, ready for you to use. These default post types include

  • Blog posts

  • Pages

  • Navigation menus

  • Attachments

  • Revisions

Custom post types give you the ability to create new and useful types of content on your website, including a smart and easy way to publish those content types to your site.

You really have endless possibilities for how to use custom post types, but here are a few ideas that can kick-start your imagination (they’re some of the most popular and useful ideas that others have implemented on their sites):

  • Photo gallery

  • Podcast or video

  • Book reviews

  • Coupons and special offers

  • Events calendar

In order to create and use custom post types on your site, you need to be sure that your WordPress theme contains the correct code and functions. The following steps, show how to create a very basic custom post type called Generic Content:

  1. Click Editor in the Appearances drop-down list to open the Theme Editor page.

  2. Click the Theme Functions template link to open the functions.php file in the text editor on the left side of the page.

  3. Scroll down to the bottom of the functions.php file and include the following code to add a Generic Content custom post type to your site:

    add_action( ‘init’, ‘create_my_post_types’ );
    function create_my_post_types() {
    register_post_type( ‘generic_content’,
    array(
    ‘label’ => __( ‘Generic Content’ ),
    ‘singular_label’ => __( ‘Generic Content’ ),
    ‘description’ => __( ‘This is a description of the Generic Content type’ ),
    ‘public’ => true,
    );
    }
  4. Click the Update File button to save the changes made to the functions.php file.

The function register_post_type can accept several different arguments and parameters, which are detailed in the following table.

Two very helpful plugins for building custom post types pretty quickly in WordPress are

  • Custom Post Types UI: Written by the folks at WebDevStudios, this plugin gives you a clean interface within your WordPress Dashboard that can help you easily and quickly build custom post types on your website. It eliminates the need to add the code to your functions.php file by giving you options and settings so that you can configure and build the custom post type that you want.

    image0.jpg
  • Verve Meta Boxes: Available from Magento Developers in the WordPress Plugin Directory, this plugin provides an interface in your Dashboard that you can use to create meta boxes, or special custom fields for the custom post types that you build.

    This example shows some custom meta boxes built by using custom post types. This website features theater productions and the custom post types for those shows. On the right side, the Purchase Link boxes were created by using custom meta boxes and give the website owner a quick and easy field to fill out so that he or she can include information on where to purchase show tickets in every show post published.

    image1.jpg
  • Add a Comment
  • Print
  • Share
blog comments powered by Disqus
Advertisement

Inside Dummies.com

Dummies.com Sweepstakes

Win $500. Easy.