Skip to content

Instantly share code, notes, and snippets.

@jsoningram
Last active August 29, 2015 14:19
Show Gist options
  • Save jsoningram/198cff6f783683aaf0a5 to your computer and use it in GitHub Desktop.
Save jsoningram/198cff6f783683aaf0a5 to your computer and use it in GitHub Desktop.
WordPress Custom Post Type
<?php
function post_type_foos() {
$post_type = 'Foos';
$singular = 'Foo';
register_post_type(strtolower($post_type),
array(
'labels' => array(
'name' => __( $post_type ),
'singular_name' => __( $post_type ),
'add_new' => __( 'Add New' ),
'add_new_item' => __( 'Add New ' . $singular ),
'edit' => __( 'Edit' ),
'edit_item' => __( 'Edit ' . $singular ),
'new_item' => __( 'New ' . $singular ),
'view' => __( 'View ' . $post_type ),
'view_item' => __( 'View ' . $singular ),
'search_items' => __( 'Search ' . $post_type ),
'not_found' => __( 'No ' . $post_type . ' found' ),
'not_found_in_trash' => __( 'No '. $post_type .' found in Trash' ),
'parent' => __( 'Parent ' . $singular ),
),
'public' => true,
'show_ui' => true,
'exclude_from_search' => true,
'hierarchical' => true,
'supports' => array( 'title','editor','excerpt','custom-fields','page-attributes', 'thumbnail' ),
'rewrite' => array( 'slug' => strtolower($post_type), 'with_front' => true ),
'query_var' => true,
)
);
} add_action('init', 'post_type_foos');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment