Created
February 29, 2016 06:51
-
-
Save amberhinds/b7353d20b4d27bf9d975 to your computer and use it in GitHub Desktop.
Register a post type in WordPress
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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