Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Creatively Creating Custom Post Types

Creatively Creating Custom Post Types

This presentation was given at WordUp MPLS 2013 about using and creating custom post types and taxonomies in WordPress.

Nikhil Vimal

October 12, 2013
Tweet

More Decks by Nikhil Vimal

Other Decks in Programming

Transcript

  1. Hi, I’m Nikhil • I develop with WordPress • I

    can be found on Twitter @TechVoltz • This my first talk ever
  2. But what are they? •Instead of using default posts and

    categories in WordPress, use Custom Post Types •You can add a lot of cool things that are not in a Default WordPress install •Added in WordPress 3.0
  3. Create a file called myposttype.php <?php /** * Plugin Name:

    Your Custom Post Type * Plugin URI: http://yourpluginswebsite.com * Description: A brief description of your Plugin. * Version: The Plugin's Version Number, e.g.: 1.0 * Author: Your Name * Author URI: http://yourwebsite.com * License: A "Slug" license name e.g. GPL2 */
  4. add_action('init', 'wordup_sessions'); function wordup_sessions() { $wordup_args = array( 'public' =>

    true, 'has_archive' => true, 'query_var' => 'wordup', 'menu_position' => 5, 'supports' => array( 'title', 'editor', 'thumbnail', 'excerpt', 'comments' ), 'labels' => array( 'name' => 'WordUp Sessions', 'singular' => 'WordUp Session', 'add_new' => 'Add Session', 'add_new_item' => 'Add Session', 'edit_item' => 'Edit Session', 'new_item' => 'New Session', 'view_item' => 'View Session', 'search_items' => 'Search WordUp', 'not_found' => 'No sessions found', 'not_found_in_trash' => 'No Sessions found in the Trash', ), ); register_post_type('WordUp', $wordup_args ); }
  5. function wordup_sessions() { $wordup_args = array( 'public' => true, 'has_archive'

    => true, 'query_var' => 'wordup', 'menu_position' => 5, 'supports' => array( 'title', 'editor', 'thumbnail', 'excerpt', 'comments' ),
  6. 'labels' => array( 'name' => 'WordUp Sessions', 'singular' => 'WordUp

    Session', 'add_new' => 'Add Session', 'add_new_item' => 'Add Session', 'edit_item' => 'Edit Session', 'new_item' => 'New Session', 'view_item' => 'View Session', 'search_items' => 'Search Sessions', 'not_found' => 'No sessions found', 'not_found_in_trash' => 'No Sessions found in the Trash', ), );
  7. 'labels' => array( 'name' => 'Tracks', 'edit_item' => 'Edit Track',

    'update_item' => 'Update Track', 'add_new_item' => 'Add New Track', 'new_item_name' => 'New Track', 'all_items' => 'All Tracks', 'search_items' => 'Search Tracks', 'popular_items' => 'Popular Tracks', 'add_or_remove_items' => 'Add or remove Tracks', 'choose_from_most_used' => 'Choose from most used Tracks', ), );