×

Welcome to TagMyCode

Please login or create account to add a snippet.
0
0
 
0
Language: PHP
Posted by: Eric De Kock
Added: Mar 2, 2017 12:41 AM
Modified: Mar 2, 2017 12:46 AM
Views: 2252
Tags: no tags
  1. /* ==========================================================================
  2.   Custom Post Types
  3.   ========================================================================== */
  4.  
  5. // Store locations - used for contact page
  6. function custom_post_type_store_location() {
  7.  
  8.     $labels = array(
  9.         'name' => _x('Store Locations', 'Post Type General Name', 'text_domain'),
  10.         'singular_name' => _x('Store Location', 'Post Type Singular Name', 'text_domain'),
  11.         'menu_name' => __('Store Locations', 'text_domain'),
  12.         'parent_item_colon' => __('Parent Store:', 'text_domain'),
  13.         'all_items' => __('All Stores', 'text_domain'),
  14.         'view_item' => __('View Store', 'text_domain'),
  15.         'add_new_item' => __('Add New Store', 'text_domain'),
  16.         'add_new' => __('Add New', 'text_domain'),
  17.         'edit_item' => __('Edit Store', 'text_domain'),
  18.         'update_item' => __('Update Store', 'text_domain'),
  19.         'search_items' => __('Search Store', 'text_domain'),
  20.         'not_found' => __('Store Not found', 'text_domain'),
  21.         'not_found_in_trash' => __('Store Not found in Trash', 'text_domain'),
  22.     );
  23.     $args = array(
  24.         'label' => __('store-location', 'text_domain'),
  25.         'description' => __('A collection of all store locations around Australia', 'text_domain'),
  26.         'labels' => $labels,
  27.         'supports' => array('title', 'page-attributes',),
  28.         'taxonomies' => array('state'),
  29.         'hierarchical' => false,
  30.         'public' => true,
  31.         'show_ui' => true,
  32.         'show_in_menu' => true,
  33.         'menu_position' => 20,
  34.         'menu_icon' => 'dashicons-location-alt',
  35.         'show_in_admin_bar' => true,
  36.         'show_in_nav_menus' => false,
  37.         'can_export' => false,
  38.         'has_archive' => false,
  39.         'exclude_from_search' => true,
  40.         'publicly_queryable' => true,
  41.         'capability_type' => 'page',
  42.     );
  43.     register_post_type('store-location', $args);
  44. }
  45.  
  46. add_action('init', 'custom_post_type_store_location', 0);
  47.  
  48. /* ==========================================================================
  49.   Custom Taxonomies
  50.   ========================================================================== */
  51.  
  52. // State Taxonomy - used for store location post type
  53. function custom_taxonomy_state() {
  54.  
  55.     $labels = array(
  56.         'name' => _x('States', 'Taxonomy General Name', 'text_domain'),
  57.         'singular_name' => _x('State', 'Taxonomy Singular Name', 'text_domain'),
  58.         'menu_name' => __('State', 'text_domain'),
  59.         'all_items' => __('All States', 'text_domain'),
  60.         'parent_item' => __('Parent State', 'text_domain'),
  61.         'parent_item_colon' => __('Parent State:', 'text_domain'),
  62.         'new_item_name' => __('New State Name', 'text_domain'),
  63.         'add_new_item' => __('Add New State', 'text_domain'),
  64.         'edit_item' => __('Edit State', 'text_domain'),
  65.         'update_item' => __('Update State', 'text_domain'),
  66.         'separate_items_with_commas' => __('Separate states with commas', 'text_domain'),
  67.         'search_items' => __('Search States', 'text_domain'),
  68.         'add_or_remove_items' => __('Add or remove states', 'text_domain'),
  69.         'choose_from_most_used' => __('Choose from the most used states', 'text_domain'),
  70.         'not_found' => __('State Not Found', 'text_domain'),
  71.     );
  72.     $args = array(
  73.         'labels' => $labels,
  74.         'hierarchical' => true,
  75.         'public' => true,
  76.         'show_ui' => true,
  77.         'show_admin_column' => true,
  78.         'show_in_nav_menus' => false,
  79.         'show_tagcloud' => false,
  80.     );
  81.     register_taxonomy('state', array('store-location'), $args);
  82. }
  83.  
  84. add_action('init', 'custom_taxonomy_state', 0);