Skip to content

Instantly share code, notes, and snippets.

@MrJoshFisher
Last active November 15, 2023 10:11
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 MrJoshFisher/dbc0cfba2255cfaabdcf68fa727f99d8 to your computer and use it in GitHub Desktop.
Save MrJoshFisher/dbc0cfba2255cfaabdcf68fa727f99d8 to your computer and use it in GitHub Desktop.
[WordPress Post Type] #WordPress Post Type
function testimonial_post_type() {
// Labels
$labels = array(
'name' => _x("Testimonials", "post type general name"),
'singular_name' => _x("Testimonial", "post type singular name"),
'menu_name' => 'Testimonials',
'add_new' => _x("Add New", "testimonial item"),
'add_new_item' => __("Add New Testimonial"),
'edit_item' => __("Edit Testimonial"),
'new_item' => __("New Testimonial"),
'view_item' => __("View Testimonial"),
'search_items' => __("Search Testimonials"),
'not_found' => __("No Testimonials Found"),
'not_found_in_trash' => __("No Testimonials Found in Trash"),
'parent_item_colon' => ''
);
// Register post type
register_post_type('testimonial' , array(
'labels' => $labels,
'description' => 'Testimonials custom post type.',
'public' => true,
'publicly_queryable' => true,
'query_var' => true,
'show_ui' => true,
'show_in_menu' => true,
'hierarchical' => true,
'capability_type' => 'post',
'menu_position' => 20,
'has_archive' => false,
'menu_icon' => 'dashicons-format-status',
'rewrite' => array( 'slug' => 'recipe' ),
'supports' => array( 'title', 'editor', 'author', 'thumbnail' ),
'show_in_rest' => true
) );
}
add_action( 'init', 'testimonial_post_type', 0 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment