Quick Tip: 3 Tools for Making “Instant” Custom Post Types

Quick Tip: 3 Tools for Making “Instant” Custom Post Types

Tutorial Details
  • Program: Wordpress
  • Version (if applicable): 3.0+
  • Difficulty: Beginner
  • Estimated Completion Time: 5-10 minutes

Custom post types are all over the place nowadays… but what if you want to get your feet wet with custom post types without all of the hassle of coding them from scratch? This quick-tip will give you 3 tools for generating (and managing!) your own custom post types without even firing up your text editor. Nothing will ever substitute being able to code these up from scratch, but this will get you started before your popcorn dings in the microwave…


Introduction

This tutorial has some basic knowledge requirements. First and foremost, you really should have at least some basic knowledge about what custom post types are and how they are intended to be used. If you don’t have a clue what post types are, please visit this tutorial to get started. This tutorial only intends to give you a faster way around to generate your custom post types and taxonomies without coding.


Tip #1 The “Custom Post Type UI” Plugin

I personally recommend this plugin because this is what I always use to manage my custom post types. It’s the perfect start for anyone trying to wrap their heads around what a Post Type can really do without needing to get elbow deep in code. Just fire up the plugin and start creating your own custom post types and taxonomies in minutes.

“This plugin provides an easy to use interface to create and administer custom post types and taxonomies in WordPress.”

This plugin is developed by Brad Williams from webdevstudios.com. Essentially, it allows you to create custom post types and taxonomies through the plugins user interface (instead of coding them from scratch).

Below is a demo on how to use this plugin, sorry for the lack of audio…

And here’s a video from Brad that includes his own voiceover of what the plugin is intended to do:

Download the plugin here, or visit the plugin homepage.


Tip #2 Use the online Custom Post Type Code Generator

This one is pretty self-explanatory – it’s the same idea as the plugin above, but it’s not integrated within WordPress, which means you can pull the code out directly and start playing with it on your own.

You can now easily, and within minutes, generate the code needed to register a custom post type for WordPress. It is done through an easy wizard-driven form that will output your code once you have filled in all the fields. No coding experience required. -Brad Vincent

This Generator was created using Gravity Forms, so we’ve officially entered the phase in WP where plugins are creating their own plugins… which begs the question, when will the Plugin Overlords stake their claim on the world? Ok, kidding, but this little app rocks.

What I love about this online code generator is that the developer explains what each field is for. It also gives you the option for menu position and the option to set the icon for your custom posts.

Sample generated code

add_action( 'init', 'register_cpt_portfolio' );

function register_cpt_portfolio() {

    $labels = array( 
        'name' => _x( 'Portfolios', 'portfolio' ),
        'singular_name' => _x( 'Portfolio', 'portfolio' ),
        'add_new' => _x( 'Add New', 'portfolio' ),
        'add_new_item' => _x( 'Add New Portfolio', 'portfolio' ),
        'edit_item' => _x( 'Edit Portfolio', 'portfolio' ),
        'new_item' => _x( 'New Portfolio', 'portfolio' ),
        'view_item' => _x( 'View Portfolio', 'portfolio' ),
        'search_items' => _x( 'Search Portfolios', 'portfolio' ),
        'not_found' => _x( 'No portfolios found', 'portfolio' ),
        'not_found_in_trash' => _x( 'No portfolios found in Trash', 'portfolio' ),
        'parent_item_colon' => _x( 'Parent Portfolio:', 'portfolio' ),
        'menu_name' => _x( 'Portfolios', 'portfolio' ),
    );

    $args = array( 
        'labels' => $labels,
        'hierarchical' => false,
        
        'supports' => array( 'title', 'editor', 'excerpt', 'author', 'thumbnail', 'custom-fields', 'revisions' ),
        'taxonomies' => array( 'category' ),
        'public' => true,
        'show_ui' => true,
        'show_in_menu' => true,
        'menu_position' => 5,
        'menu_icon' => 'http://yourdomain.com/images/menuicon.png',
        'show_in_nav_menus' => true,
        'publicly_queryable' => true,
        'exclude_from_search' => true,
        'has_archive' => true,
        'query_var' => true,
        'can_export' => true,
        'rewrite' => true,
        'capability_type' => 'post'
    );

    register_post_type( 'portfolio', $args );
}

Visit the Custom Post Type Code Generator, you can also use the Custom Taxonomy Code Generator


Tip #3: The Post Type ReOrder Plugin

This handy little plugin uses drag and drop sortable Javascript, which is a fancy way of saying it’s user friendly. It allows you to reorder the posts for any custom post types you defined, including the default Posts and Pages. Also you can have the admin posts interface sorted per your new sort. Great, right?!

After you successfully installed and activate the plugin, you will be prompted to configure and save the settings of the plugin.

Features of the plugin:

  • You will be able to order all wordpress custom post types order including the default posts and pages.
  • Easy to use Drag & Drop jquery style interface to allow re-order.
  • Allow WordPress Admin Interface Order
  • If your theme is not ready to use additional sort features, you don’t need to worry, the plugin will automatically do that for you, on the fly.
  • The admin can set the minimum level for a user type which will be able to do sorts.

Download and install the plugin


/QuickTip

Alright, so we’ve dished out three quick ideas for getting your feet wet with custom post types… in the weeks to come, we’ll actually be digging a lot further into the topic though. So the idea is that you can always come back to this post and “hit the easy button” if you decide to duck out of class when your brain starts hurting.

Note: Want to add some source code? Type <pre><code> before it and </code></pre> after it. Find out more
  • http://curtismchale.ca curtismchale

    While these are neat I’ve already encountered clients that screwed up their sites by inserting code without really knowing what they should. I kinda wish they didn’t exist so that the bar for adding CPT was high enough. I also don’t find them faster than inserting the proper code from Codebox. Once you’ve got it in a simple find/replace and you’re done.

    • Brandon Jones

      I totally agree – these are awesome for getting started if you’re a new WP dev and you’re looking for a way to play around a bit before diving into writing it from scratch (or for quickly prototyping CPT ideas that you’ll re-write later), but ultimately a lot of these custom-post snippets probably would do well to be baked into a theme or (even better) placed as a plugin into the mu-plugins folder so clients can’t break ‘em by getting curious ;)

      With that said, anytime you’re going to be adding anything that messes with the WP GUI, it’s not to be taken lightly… every situation is going to have a “right” answer that may be different from others. If I’m working on a one-off client project, I’m probably going to call CPT from a plugin file that’s nested safely inside the mu-plugins folder. If I’m working CPTs into a theme (ugh), I’m probably going to make this a detachable file that’s referenced from functions.php (so users can always move it to their new theme later on).

  • http://czent.com/ Deb

    Also the “More Types” plugin.

    • Brandon Jones

      Thanks for the reference Deb!

  • Darin Roman

    I’ve just started adding CPTs to my custom themes and find this topic is being approached here just at the time I need it to be. I hope the upcoming tuts will go into more depth than most of the others I’ve found on custom post types and taxonomies. Registering these are easy enough to accomplish via functions.php, even for a beginner. What I’d really like to learn more about is creating the appropriate single & archive templates for front end output, as well as, some real world examples of displaying various multiple post types via the templates for true CMS flexibility.

    I find there is also a lack of information about a related topic:The creation of meta boxes/fields for our custom post types and how to output this custom data in the templates. Please cover this! Custom fields are awkward and sometimes difficult to explain to clients. Having customized and clearly labeled meta boxes would be much more intuitive, attractive and simply make sense. Why should we only go half way when developing our custom content types?

    Using these plugins and tools can definitely aid in development speed up production, however, I’d opt for the online generator and keep the plugins away from the meddling of curious clients. There is an excellent plugin on CodeCanyon by Pippin > Easy Custom Content Types for WordPress for creating custom post types, taxonomies and also meta boxes. This plugin will also export the code for the post types and taxonomies (no meta box output yet…sigh) so you can develop everything you need, then drop the code into your functions.php and remove the plugin if you’d like.

    • Darin Roman

      I just noticed the previous post in this series had addressed meta boxes…forgive my ignorance and thank you for fulfilling my request in retrospect.

      • http://pippinsplugins.com Pippin

        Thanks for the mention :)

  • http://www.derby-webdesign.co.uk Kevin

    I’m surprised you didnt mention the Easy Custom Content Types plugin on Code Canyon being part of the Envato network. I use this plugin and it’s excellent – http://codecanyon.net/item/easy-custom-content-types-for-wordpress/234182

    I really like the Post Type ReOrder Plugin however, I’ll deffinatly be trying that out =)

    • http://pippinsplugins.com Pippin

      I appreciate your mention :)

    • Brandon Jones

      Thanks for the heads up Kevin – I’ll have to check that one out myself, but it looks pretty great on the surface!

  • http://pippinsplugins.com Pippin

    One good way of ensuring clients don’t screw up post types (if you’re using a plugin such as mine or Custom Post Types UI) is to set a user level restriction on the plugin menu pages. Very rarely do I give my clients Administrator user levels (they just don’t need it), so if you restrict the pages to admins only, problem is solved.

    Much like Brandon said, I always include my custom post types in either a plugin file or a separate file called from functions.php. Not only does this make the theme code cleaner, but it always make it very easy to migrate the custom post types.

    • http://jholmberg.com Johannes Holmberg

      Totally agree with you Pippin. I always keep my code for creating custom post types in a functionality plugin for the site. So much easier to migrate at a later stage.

  • Pingback: Using Custom Post Types to Create a Killer Portfolio | Wptuts+

  • Pingback: Best WordPress Tips and Tutorials | Designs Showcase

  • Pingback: Quality Tutorials For Creating WordPress Custom Post Types | Design Woop | The Web Design and Development Blog

  • Pingback: Gestione dei Custom Post e dei Custom Fields in Wordpress - diploD