Skip to content

Instantly share code, notes, and snippets.

@amberhinds
Created February 29, 2016 06:51
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 amberhinds/b7353d20b4d27bf9d975 to your computer and use it in GitHub Desktop.
Save amberhinds/b7353d20b4d27bf9d975 to your computer and use it in GitHub Desktop.
Register a post type in WordPress
<?php
//* This file adds the custom post type to our testimonials plugin with a taxonomy and custom meta box options.
/**
* Create testimonials custom post type.
*
* Registers the testimonial custom post type.
*
* @see register_post_type
*/
add_action( 'init', 'fcwp_testimonials_post_type' );
function fcwp_testimonials_post_type() {
$labels = array(
'name' => _x( 'Testimonials', 'post type general name', 'fcwp-testimonials' ),
'singular_name' => _x( 'Testimonial', 'post type singular name', 'fcwp-testimonials' ),
'menu_name' => _x( 'Testimonials', 'admin menu', 'fcwp-testimonials' ),
'name_admin_bar' => _x( 'Testimonial', 'add new on admin bar', 'fcwp-testimonials' ),
'add_new' => _x( 'Add New', 'testimonial', 'fcwp-testimonials' ),
'add_new_item' => __( 'Add New Testimonial', 'fcwp-testimonials' ),
'new_item' => __( 'New Testimonial', 'fcwp-testimonials' ),
'edit_item' => __( 'Edit Testimonial', 'fcwp-testimonials' ),
'view_item' => __( 'View Testimonial', 'fcwp-testimonials' ),
'all_items' => __( 'All Testimonials', 'fcwp-testimonials' ),
'search_items' => __( 'Search Testimonials', 'fcwp-testimonials' ),
'parent_item_colon' => __( 'Parent Testimonials:', 'fcwp-testimonials' ),
'not_found' => __( 'No testimonials found.', 'fcwp-testimonials' ),
'not_found_in_trash' => __( 'No testimonials found in Trash.', 'fcwp-testimonials' )
);
$args = array(
'labels' => $labels,
'has_archive' => true,
'public' => true,
'rewrite' => array( 'slug' => 'testimonial' ),
'supports' => array( 'title', 'editor', 'excerpt', 'thumbnail' ),
'menu_position' => 5,
'menu_icon' => 'dashicons-testimonial',
);
register_post_type( 'testimonial', $args );
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment