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

Custom Post Types

Roy Tanck
January 29, 2015

Custom Post Types

Slides van mijn presentatie bij de WordPress meetup in Utrecht, op 29 januari 2015.

Roy Tanck

January 29, 2015
Tweet

More Decks by Roy Tanck

Other Decks in Programming

Transcript

  1. WordPress milestones 0.7 - Fork van B2/Cafelog 1.0 - 5

    min. install, permalinks, etc… 1.2 - Plugins 1.5 - Themes, pages(!) 2.3 - Custom Taxonomies (bruikbaar > 2.8) 3.0 - Custom Post Types (bruikbaar > 3.2)
  2. ?>

  3. /** * Plugin Name: RT Projects * Plugin URI: http://www.this-play.nl

    * Description: Adds a “Projects” CPT. * Version: 1.0 * Author: Roy Tanck * Author URI: http://www.roytanck.com * License: GPL2 */
  4. function rt_add_post_type() { $args = array( 'public' => true, 'label'

    => 'Projects' ); register_post_type( 'rt_project', $args ); }
  5. $args = array( 'labels' => $labels, 'public' => true, 'rewrite'

    => array('slug'=>'projects'), 'capability_type' => 'post', 'has_archive' => true, 'hierarchical' => false, 'supports' => array('title','editor', 'thumbnail','excerpt') );
  6. $labels = array( 'name' => _x( 'Projects', 'post type general

    name', 'rt-projects' ), 'singular_name' => _x( 'Project', 'post type singular name', 'rt-projects' ), 'menu_name' => _x( 'Projects', 'admin menu', 'rt-projects' ), 'name_admin_bar' => _x( 'Project', 'add new on admin bar', 'rt-projects' ), 'add_new' => _x( 'Add New', 'project', 'rt-projects' ), 'add_new_item' => __( 'Add New Project', 'rt-projects' ), 'new_item' => __( 'New Project', 'rt-projects' ), 'edit_item' => __( 'Edit Project', 'rt-projects' ), 'view_item' => __( 'View Project', 'rt-projects' ), 'all_items' => __( 'All Projects', 'rt-projects' ), 'search_items' => __( 'Search Projects', 'rt-projects' ), 'parent_item_colon' => __( 'Parent Projects:', 'rt-projects' ), 'not_found' => __( 'No projects found.', 'rt-projects' ), 'not_found_in_trash' => __( 'No projects found in Trash.', 'rt-projects' ) );