amy-d
9/13/2014 - 2:08 PM

PHP - WP: Custom Post Type Plugin

PHP - WP: Custom Post Type Plugin

<?php
/*
Plugin Name: Custom Post Types
Plugin URI: http://www.amyhaywood.com/
Description: Declares a plugin that will create custom post types
Version: 1.0
Author: Amy Haywood Dutton
Author URI: http://www.ahhacreative.com/
*/

add_action( 'init', 'create_custom_post_types' );
function create_custom_post_types() {

	/**
	 * 
	 * PORTFOLIO PIECES
	 * 
	 */
	
	// register custom post type
    register_post_type( 'portfolio',
        array(
            'labels' => array(
                'name' => 'Portfolio',
                'singular_name' => 'Portfolio',
                'add_new' => 'Add New',
                'add_new_item' => 'Add New Portfolio',
                'edit' => 'Edit',
                'edit_item' => 'Edit Portfolio',
                'new_item' => 'New Portfolio',
                'view' => 'View',
                'view_item' => 'View Portfolio',
                'search_items' => 'Search Portfolio',
                'not_found' => 'No Portfolios found',
                'not_found_in_trash' => 'No Portfolios found in Trash',
                'parent' => 'Parent Portfolio'
            ),
 
            'public' => true,
            'hierarchical' => true,
            'menu_position' => 15,
            'supports' => array( 'title', 'editor', 'thumbnail' ),
            'menu_icon' => 'dashicons-format-image',
            'has_archive' => true
        )
    );
    // register categories for portfolio items
    register_taxonomy("portfolio_categories", array("portfolio"), array("hierarchical" => true, "label" => "Categories", "singular_label" => "Category", "rewrite" => true));


}