-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcustom-posts.php
More file actions
267 lines (196 loc) · 7.03 KB
/
Copy pathcustom-posts.php
File metadata and controls
267 lines (196 loc) · 7.03 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
<?php
// Adding custom posts
// Masters posts
function master_post_type() {
$args = array (
'labels'=> array (
'name' => 'Masters', // label shown in admin menu
'singular_name' => 'master', // name for one object of the post type
),
'hierarchical' => true,
'public' => true, // visible both in the admin panel and front end
'has_archive' => true, // enables archiving of the custom posts
'menu_icon' => 'dashicons-universal-access-alt', // post type icon in admin menu
'rewrite' => array('slug' => 'masters','with_front' => false),
'supports' => array(
'title',
'editor',
'author',
'thumbnail',
'custom-fields',
'page-attributes',
'post-formats',
'custom-fields',),// features supported by the post type
'show_in_rest' => true, // for API endpoint
);
register_post_type('master', $args);
}
add_action('init', 'master_post_type'); // fires after loadng is completed but before any headers sent
// Photos for galleries
function photo_post_type() {
$args = array (
'labels'=> array (
'name' => 'Photos', // label shown in admin menu
'singular_name' => 'photo', // name for one object of the post type
),
'public' => true, // visible both in the admin panel and front end
'has_archive' => true, // enables archiving of the custom posts
'menu_icon' => 'dashicons-format-gallery', // post type icon in admin menu
'rewrite' => array('slug' => 'photos','with_front' => false),
'supports' => array(
'title',
'editor',
'author',
'thumbnail',
'custom-fields',
'page-attributes',
'post-formats',
'custom-fields'),// features supported by the post type
'show_in_rest' => true, // for API endpoint
);
register_post_type('photo', $args);
}
add_action('init', 'photo_post_type'); // fires after loadng is completed but before any headers sent
// adding thumbnails to the admin post list
if (function_exists('add_theme_support')) {
add_theme_support( 'post-thumbnails' );
set_post_thumbnail_size( 100, 100, true ); // default thumbnail size
add_image_size('my-custom-thumb', 120, 120, true); //custom size
}
add_filter('manage_posts_columns', 'posts_columns', 5);
add_action('manage_posts_custom_column', 'posts_custom_columns', 5, 2);
function posts_columns($defaults){
$defaults['riv_post_thumbs'] = __('Pic');
return $defaults;
}
function posts_custom_columns($column_name, $id){
if($column_name === 'riv_post_thumbs'){
echo the_post_thumbnail();
}
}
// Adding custom taxonomies
function type_master_taxonomy() {
$args = array (
'labels'=> array (
'name' => 'master', // label shown in admin menu
'singular_name' => 'master',
),
'public' => true, // visible both in the admin panel and front end
'hierarchical' => true, // category-kind taxonomy
'show_in_rest' => true, // for API endpoint
);
register_taxonomy('master', array('photo'), $args);
}
add_action('init', 'type_master_taxonomy'); // fires after loadng is completed but before any headers sent
// Custom posts for contact details
function some_post_type() {
$args = array (
'labels'=> array (
'name' => 'All Contact Info', // label shown in admin menu
'singular_name' => 'some', // name for one object of the post type
),
'public' => true, // visible both in the admin panel and front end
'has_archive' => true, // enables archiving of the custom posts
'menu_icon' => 'dashicons-share', // post type icon in admin menu
'rewrite' => array('slug' => 'some','with_front' => false),
'supports' => array('title', 'editor', 'thumbnail', 'custom-fields'), // features supported by the post type
'show_in_rest' => true, // for API endpoint
);
register_post_type('some', $args);
}
add_action('init', 'some_post_type');
// Customs posts for Our Story section
function story_post_type() {
$args = array (
'labels'=> array (
'name' => 'Our Story', // label shown in admin menu
'singular_name' => 'story', // name for one object of the post type
),
'public' => true, // visible both in the admin panel and front end
'has_archive' => true, // enables archiving of the custom posts
'menu_icon' => 'dashicons-buddicons-community', // post type icon in admin menu
'rewrite' => array('slug' => 'story','with_front' => false),
'supports' => array('title', 'editor', 'thumbnail', 'custom-fields'), // features supported by the post type
'show_in_rest' => true, // for API endpoint
);
register_post_type('story', $args);
}
add_action('init', 'story_post_type');
// Customs posts for Services in Master Profiles
function service_post_type() {
$args = array (
'labels'=> array (
'name' => 'Services and Products', // label shown in admin menu
'singular_name' => 'service', // name for one object of the post type
),
'public' => true, // visible both in the admin panel and front end
'has_archive' => true, // enables archiving of the custom posts
'menu_icon' => 'dashicons-admin-tools', // post type icon in admin menu
'rewrite' => array('slug' => 'service','with_front' => false),
'supports' => array(
'title',
'editor',
'author',
'thumbnail',
'custom-fields',
'page-attributes',
'post-formats',
'custom-fields'),// features supported by the post type
'show_in_rest' => true, // for API endpoint
);
register_post_type('service', $args);
}
add_action('init', 'service_post_type'); // fires after loadng is completed but before any headers sent
// Adding custom taxonomies for Services and Products
function type_service_taxonomy() {
$args = array (
'labels'=> array (
'name' => 'service types', // label shown in admin menu
'singular_name' => 'servicetype',
),
'public' => true, // visible both in the admin panel and front end
'hierarchical' => true, // category-kind taxonomy
'show_in_rest' => true, // for API endpoint
);
register_taxonomy('servicetype', array('service'), $args);
}
add_action('init', 'type_service_taxonomy'); // fires after loadng is completed but before any headers sent
function service_type_master_taxonomy() {
$args = array (
'labels'=> array (
'name' => 'by masters', // label shown in admin menu
'singular_name' => 'by master',
),
'public' => true, // visible both in the admin panel and front end
'hierarchical' => true, // category-kind taxonomy
'show_in_rest' => true, // for API endpoint
);
register_taxonomy('by master', array('service'), $args);
}
add_action('init', 'service_type_master_taxonomy'); // fires after loadng is completed but before any headers sent
// adding offer page post type
function offer_post_type() {
$args = array (
'labels'=> array (
'name' => 'Offers', // label shown in admin menu
'singular_name' => 'offer', // name for one object of the post type
),
'hierarchical' => true,
'public' => true, // visible both in the admin panel and front end
'has_archive' => true, // enables archiving of the custom posts
'menu_icon' => 'dashicons-money-alt', // post type icon in admin menu
'rewrite' => array('slug' => 'offers','with_front' => false),
'supports' => array(
'title',
'editor',
'author',
'thumbnail',
'custom-fields',
'page-attributes',
'post-formats',
'custom-fields',),// features supported by the post type
'show_in_rest' => true, // for API endpoint
);
register_post_type('offer', $args);
}
add_action('init', 'offer_post_type');