Advertisement
olie480

WP - Custom Post Type Snippet

Sep 16th, 2013
56
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.67 KB | None | 0 0
  1. <?php
  2.  
  3. /* ------------------------------------*\
  4.   Custom Post Types
  5.   \*------------------------------------ */
  6.  
  7. add_action('init', 'create_post_types'); // Add our Post Types
  8.  
  9. function create_post_types() {
  10.    
  11.     register_taxonomy_for_object_type('category', 'html5-blank'); // Register Taxonomies for Category
  12.     register_taxonomy_for_object_type('post_tag', 'html5-blank');
  13.  
  14.  
  15.     register_post_type('galleries', // Register Custom Post Type
  16.             array(
  17.         'labels' => array(
  18.             'name' => __('Gallery'), // Rename these to suit
  19.             'singular_name' => __('Gallery'),
  20.             'add_new' => __('Add New'),
  21.             'add_new_item' => __('Add New Gallery'),
  22.             'edit' => __('Edit'),
  23.             'edit_item' => __('Edit Gallery'),
  24.             'new_item' => __('New Gallery'),
  25.             'view' => __('View Gallery'),
  26.             'view_item' => __('View Gallery'),
  27.             'search_items' => __('Search Galleries'),
  28.             'not_found' => __('No Galleries found'),
  29.             'not_found_in_trash' => __('No Galleries found in Trash')
  30.         ),
  31.         'public' => true,
  32.         'hierarchical' => true, // Allows your posts to behave like Hierarchy Pages
  33.         'has_archive' => true,
  34.         'supports' => array(
  35.             'title',
  36.             'editor',
  37.             'excerpt',
  38.             'thumbnail',
  39.             'custom-fields',
  40.         ), // Go to Dashboard Custom HTML5 Blank post for supports
  41.         'can_export' => true, // Allows export in Tools > Export
  42.         'taxonomies' => array(
  43.             'post_tag',
  44.             'category'
  45.         ) // Add Category and Post Tags support
  46.     ));
  47. }
  48.  
  49. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement