Skip to content

Instantly share code, notes, and snippets.

@devinsays
Created November 10, 2017 03:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save devinsays/62036e1ef1ea6d79318b4c3b0ff9bae1 to your computer and use it in GitHub Desktop.
Save devinsays/62036e1ef1ea6d79318b4c3b0ff9bae1 to your computer and use it in GitHub Desktop.
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