SHOW:
|
|
- or go back to the newest paste.
1 | <?php | |
2 | /* | |
3 | Plugin Name: Listings | |
4 | - | Plugin URI: http://example.co.uk/ |
4 | + | Plugin URI: http://martcol.co.uk/ |
5 | Description: Declares a plugin that will create a custom post type displaying Neighbourgood Listings. | |
6 | Version: 1.0 | |
7 | Author: Martin Coleman on the back of the WP Generator | |
8 | - | Author URI: http://example.co.uk/ |
8 | + | Author URI: http://martcol.co.uk/ |
9 | License: GPLv2 | |
10 | */ | |
11 | //Custom Post Type for Listing | |
12 | ||
13 | if ( ! function_exists('nbrgd_listing') ) { | |
14 | ||
15 | // Register Custom Post Type | |
16 | function nbrgd_listing() { | |
17 | $labels = array( | |
18 | 'name' => _x( 'Listings', 'Post Type General Name', 'text_domain' ), | |
19 | 'singular_name' => _x( 'Listing', 'Post Type Singular Name', 'text_domain' ), | |
20 | 'menu_name' => __( 'NBRGD Listing', 'text_domain' ), | |
21 | 'parent_item_colon' => __( 'Parent Organisation', 'text_domain' ), | |
22 | 'all_items' => __( 'Listings', 'text_domain' ), | |
23 | 'view_item' => __( 'View Listings', 'text_domain' ), | |
24 | 'add_new_item' => __( 'Add New Listing', 'text_domain' ), | |
25 | 'add_new' => __( 'New Listing', 'text_domain' ), | |
26 | 'edit_item' => __( 'Edit Listing', 'text_domain' ), | |
27 | 'update_item' => __( 'Update Listing', 'text_domain' ), | |
28 | 'search_items' => __( 'Search Listings', 'text_domain' ), | |
29 | 'not_found' => __( 'Listings Not Found', 'text_domain' ), | |
30 | 'not_found_in_trash' => __( 'No Listings in Trash', 'text_domain' ), | |
31 | ); | |
32 | ||
33 | $args = array( | |
34 | 'label' => __( 'Listing', 'text_domain' ), | |
35 | 'description' => __( 'Neighbourgood Listing', 'text_domain' ), | |
36 | 'labels' => $labels, | |
37 | 'supports' => array( 'title', 'editor', 'excerpt', 'author', 'thumbnail', 'comments', 'trackbacks', 'custom-fields', 'page-attributes', ), | |
38 | - | 'taxonomies' => array( 'category', 'organisation' ),//, 'region', 'sub_type''post_tag', |
38 | + | 'taxonomies' => array( 'post_type', 'organisation', 'organisation_sub', 'region' ),//, 'region', 'sub_type' 'category', |
39 | 'hierarchical' => true, | |
40 | 'public' => true, | |
41 | 'show_ui' => true, | |
42 | 'show_in_menu' => true, | |
43 | 'show_in_nav_menus' => true, | |
44 | 'show_in_admin_bar' => true, | |
45 | 'menu_position' => 10, | |
46 | 'menu_icon' => '/img/icon.img', | |
47 | 'can_export' => true, | |
48 | 'has_archive' => true, | |
49 | 'exclude_from_search' => false, | |
50 | 'publicly_queryable' => true, | |
51 | 'capability_type' => 'post', | |
52 | ); | |
53 | ||
54 | - | register_post_type( 'Listing', $args ); |
54 | + | register_post_type( 'listing', $args ); |
55 | } | |
56 | ||
57 | // Hook into the 'init' action | |
58 | add_action( 'init', 'nbrgd_listing', 0 ); | |
59 | ||
60 | } | |
61 | // Register Custom Taxonomy | |
62 | - | if ( ! function_exists('custom_taxonomy') ) { |
62 | + | if ( ! function_exists('custom_taxonomy_listing') ) { |
63 | ||
64 | // Register Custom Taxonomy | |
65 | - | function custom_taxonomy() { |
65 | + | function custom_taxonomy_listing() { |
66 | $labels = array( | |
67 | 'name' => _x( 'Organisation Types', 'Taxonomy General Name', 'text_domain' ), | |
68 | 'singular_name' => _x( 'Organisation Type', 'Taxonomy Singular Name', 'text_domain' ), | |
69 | 'menu_name' => __( 'Organisation Type', 'text_domain' ), | |
70 | 'all_items' => __( 'All Organisation Types', 'text_domain' ), | |
71 | 'parent_item' => __( 'Parent Organisation Type', 'text_domain' ), | |
72 | 'parent_item_colon' => __( 'Parent Organisation', 'text_domain' ), | |
73 | 'new_item_name' => __( 'New Organisation Type', 'text_domain' ), | |
74 | 'add_new_item' => __( 'Add New Organisation Type', 'text_domain' ), | |
75 | 'edit_item' => __( 'Edit Organisation Type', 'text_domain' ), | |
76 | 'update_item' => __( 'Update Organisation Type', 'text_domain' ), | |
77 | 'separate_items_with_commas' => __( 'Separate Organisation Types with commas', 'text_domain' ), | |
78 | 'search_items' => __( 'Search Organisation Type', 'text_domain' ), | |
79 | 'add_or_remove_items' => __( 'Add or remove Organisation Type', 'text_domain' ), | |
80 | 'choose_from_most_used' => __( 'Choose from the most used Organisation Type', 'text_domain' ), | |
81 | ); | |
82 | ||
83 | $args = array( | |
84 | 'labels' => $labels, | |
85 | 'hierarchical' => true, | |
86 | 'public' => true, | |
87 | 'show_ui' => true, | |
88 | 'show_admin_column' => true, | |
89 | 'show_in_nav_menus' => true, | |
90 | 'show_tagcloud' => true, | |
91 | ); | |
92 | ||
93 | - | register_taxonomy( 'organisation', 'custom_post_type', $args ); |
93 | + | register_taxonomy( 'organisation', 'listing', $args ); |
94 | ||
95 | $labels = array( | |
96 | 'name' => _x( 'Organisation Sub-Types', 'Taxonomy General Name', 'text_domain' ), | |
97 | - | add_action( 'init', 'custom_taxonomy', 0 ); |
97 | + | 'singular_name' => _x( 'Organisation Sub-Type', 'Taxonomy Singular Name', 'text_domain' ), |
98 | 'menu_name' => __( 'Organisation Sub-Type', 'text_domain' ), | |
99 | 'all_items' => __( 'All Organisation Sub-Types', 'text_domain' ), | |
100 | 'parent_item' => __( 'Parent Organisation Sub-Type', 'text_domain' ), | |
101 | 'parent_item_colon' => __( 'Parent Organisation', 'text_domain' ), | |
102 | 'new_item_name' => __( 'New Organisation Sub-Type', 'text_domain' ), | |
103 | 'add_new_item' => __( 'Add New Organisation Sub-Type', 'text_domain' ), | |
104 | 'edit_item' => __( 'Edit Organisation Sub-Type', 'text_domain' ), | |
105 | 'update_item' => __( 'Update Organisation Sub-Type', 'text_domain' ), | |
106 | 'separate_items_with_commas' => __( 'Separate Organisation vTypes with commas', 'text_domain' ), | |
107 | 'search_items' => __( 'Search Organisation Sub-Type', 'text_domain' ), | |
108 | 'add_or_remove_items' => __( 'Add or remove Organisation Sub-Type', 'text_domain' ), | |
109 | 'choose_from_most_used' => __( 'Choose from the most used Organisation Sub-Type', 'text_domain' ), | |
110 | ); | |
111 | ||
112 | $args = array( | |
113 | 'labels' => $labels, | |
114 | 'hierarchical' => true, | |
115 | 'public' => true, | |
116 | 'show_ui' => true, | |
117 | 'show_admin_column' => true, | |
118 | 'show_in_nav_menus' => true, | |
119 | 'show_tagcloud' => true, | |
120 | ); | |
121 | ||
122 | register_taxonomy( 'organisation_sub', 'listing', $args ); | |
123 | ||
124 | ||
125 | $labels = array( | |
126 | 'name' => _x( 'Regions', 'Taxonomy General Name', 'text_domain' ), | |
127 | 'singular_name' => _x( 'Region', 'Taxonomy Singular Name', 'text_domain' ), | |
128 | 'menu_name' => __( 'Region', 'text_domain' ), | |
129 | 'all_items' => __( 'All Regions', 'text_domain' ), | |
130 | 'parent_item' => __( 'Parent Organisation Sub-Type', 'text_domain' ), | |
131 | 'new_item_name' => __( 'New Region', 'text_domain' ), | |
132 | 'add_new_item' => __( 'Add New Region', 'text_domain' ), | |
133 | 'edit_item' => __( 'Edit Region', 'text_domain' ), | |
134 | 'update_item' => __( 'Update Region', 'text_domain' ), | |
135 | 'separate_items_with_commas' => __( 'Separate Regions with commas', 'text_domain' ), | |
136 | 'search_items' => __( 'Search Regions', 'text_domain' ), | |
137 | 'add_or_remove_items' => __( 'Add or remove Region', 'text_domain' ), | |
138 | 'choose_from_most_used' => __( 'Choose from the most used Region', 'text_domain' ), | |
139 | ); | |
140 | ||
141 | $args = array( | |
142 | 'labels' => $labels, | |
143 | 'hierarchical' => true, | |
144 | 'public' => true, | |
145 | 'show_ui' => true, | |
146 | 'show_admin_column' => true, | |
147 | 'show_in_nav_menus' => true, | |
148 | 'show_tagcloud' => true, | |
149 | ); | |
150 | ||
151 | register_taxonomy( 'region', 'listing', $args ); | |
152 | } | |
153 | ||
154 | ||
155 | ||
156 | // Hook into the 'init' action | |
157 | add_action( 'init', 'custom_taxonomy_listing', 0 ); | |
158 | ||
159 | } |