Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Portfolio Post Type Gist
<?php
/*
Plugin Name: Portfolio Post Type Gist
Plugin URI: https://wptheming.com
Description: Enables a portfolio post type and taxonomies.
Version: 0.1
Author: Devin Price
Author URI: https://wptheming.com/portfolio-post-type/
License: GPLv2
*/
function portfolioposttype() {
/**
* Enable the Portfolio custom post type
* http://codex.wordpress.org/Function_Reference/register_post_type
*/
$labels = array(
'name' => __( 'Portfolio', 'portfolioposttype' ),
'singular_name' => __( 'Portfolio Item', 'portfolioposttype' ),
'add_new' => __( 'Add New Item', 'portfolioposttype' ),
'add_new_item' => __( 'Add New Portfolio Item', 'portfolioposttype' ),
'edit_item' => __( 'Edit Portfolio Item', 'portfolioposttype' ),
'new_item' => __( 'Add New Portfolio Item', 'portfolioposttype' ),
'view_item' => __( 'View Item', 'portfolioposttype' ),
'search_items' => __( 'Search Portfolio', 'portfolioposttype' ),
'not_found' => __( 'No portfolio items found', 'portfolioposttype' ),
'not_found_in_trash' => __( 'No portfolio items found in trash', 'portfolioposttype' )
);
$args = array(
'labels' => $labels,
'public' => true,
'supports' => array( 'title', 'editor', 'thumbnail', 'comments' ),
'capability_type' => 'post',
'rewrite' => array( 'slug' => 'portfolio' ), // Permalinks format
'menu_position' => 5,
'has_archive' => true,
'menu_icon' => 'dashicons-portfolio',
);
register_post_type( 'portfolio', $args );
}
add_action( 'init', 'portfolioposttype' );
// Allow thumbnails to be used on portfolio post type
add_theme_support( 'post-thumbnails', array( 'portfolio' ) );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.