Parcourir la source

added custom column post type in admin

tags/0.9.0
Alej il y a 4 ans
Parent
révision
2355a55572
1 fichiers modifiés avec 151 ajouts et 1 suppressions
  1. 151
    1
      vue-theme/functions.php

+ 151
- 1
vue-theme/functions.php Voir le fichier

@@ -167,4 +167,154 @@ add_action( 'after_setup_theme', 'craft_post_thumbnails' );
167 167
 
168 168
 // Gutenberg custom stylesheet for editor
169 169
 add_theme_support('editor-styles');
170
-add_editor_style( 'editor-style.css' );
170
+add_editor_style( 'editor-style.css' );
171
+
172
+// Add the custom columns for EVENT:
173
+add_filter( 'manage_event_posts_columns', 'set_custom_edit_event_columns' );
174
+function set_custom_edit_event_columns($columns) {
175
+    $date = $columns['date'];
176
+    unset( $columns['date'] );
177
+    $columns['event_type'] = __('Event Type');
178
+    $columns['date'] = $date;
179
+    return $columns;
180
+}
181
+// Add the data to the custom columns for EVENT:
182
+add_action( 'manage_event_posts_custom_column' , 'custom_event_column', 10, 2 );
183
+function custom_event_column( $column, $post_id ) {
184
+    switch ( $column ) {
185
+        case 'event_type' :
186
+            $terms = get_the_term_list( $post_id , 'event_type' , '' , ',' , '' );
187
+            echo is_string( $terms ) ? $terms : '—';
188
+            break;
189
+    }
190
+}
191
+
192
+// Add the custom columns for ARTIST:
193
+add_filter( 'manage_artist_posts_columns', 'set_custom_edit_artist_columns' );
194
+function set_custom_edit_artist_columns($columns) {
195
+    $date = $columns['date'];
196
+    unset( $columns['date'] );
197
+    $columns['artist_type'] = __('Artist Type');
198
+    $columns['material'] = __('Material');
199
+    $columns['date'] = $date;
200
+    return $columns;
201
+}
202
+// Add the data to the custom columns for ARTIST:
203
+add_action( 'manage_artist_posts_custom_column' , 'custom_artist_column', 10, 2 );
204
+function custom_artist_column( $column, $post_id ) {
205
+    switch ( $column ) {
206
+        case 'artist_type' :
207
+            $terms = get_the_term_list( $post_id , 'artist_type' , '' , ',' , '' );
208
+            echo is_string( $terms ) ? $terms : '—';
209
+            break;
210
+        case 'material' :
211
+            $terms = get_the_term_list( $post_id , 'material' , '' , ',' , '' );
212
+            echo is_string( $terms ) ? $terms : '—';
213
+            break;
214
+    }
215
+}
216
+
217
+// Add the custom columns for SHORT:
218
+add_filter( 'manage_short_posts_columns', 'set_custom_edit_short_columns' );
219
+function set_custom_edit_short_columns($columns) {
220
+    $date = $columns['date'];
221
+    unset( $columns['date'] );
222
+    $columns['material'] = __('Material');
223
+    $columns['date'] = $date;
224
+    return $columns;
225
+}
226
+// Add the data to the custom columns for SHORT:
227
+add_action( 'manage_short_posts_custom_column' , 'custom_short_column', 10, 2 );
228
+function custom_short_column( $column, $post_id ) {
229
+    switch ( $column ) {
230
+        case 'material' :
231
+            $terms = get_the_term_list( $post_id , 'material' , '' , ',' , '' );
232
+            echo is_string( $terms ) ? $terms : '—';
233
+            break;
234
+    }
235
+}
236
+
237
+// Add the custom columns for GUIDE:
238
+add_filter( 'manage_guide_posts_columns', 'set_custom_edit_guide_columns' );
239
+function set_custom_edit_guide_columns($columns) {
240
+    $date = $columns['date'];
241
+    unset( $columns['date'] );
242
+    $columns['material'] = __('Material');
243
+    $columns['date'] = $date;
244
+    return $columns;
245
+}
246
+// Add the data to the custom columns for GUIDE:
247
+add_action( 'manage_guide_posts_custom_column' , 'custom_guide_column', 10, 2 );
248
+function custom_guide_column( $column, $post_id ) {
249
+    switch ( $column ) {
250
+        case 'material' :
251
+            $terms = get_the_term_list( $post_id , 'material' , '' , ',' , '' );
252
+            echo is_string( $terms ) ? $terms : '—';
253
+            break;
254
+    }
255
+}
256
+
257
+// Add the custom columns for OBJECT:
258
+add_filter( 'manage_object_posts_columns', 'set_custom_edit_object_columns' );
259
+function set_custom_edit_object_columns($columns) {
260
+    $date = $columns['date'];
261
+    unset( $columns['date'] );
262
+    $columns['material'] = __('Material');
263
+    $columns['date'] = $date;
264
+    return $columns;
265
+}
266
+// Add the data to the custom columns for OBJECT:
267
+add_action( 'manage_object_posts_custom_column' , 'custom_object_column', 10, 2 );
268
+function custom_object_column( $column, $post_id ) {
269
+    switch ( $column ) {
270
+        case 'material' :
271
+            $terms = get_the_term_list( $post_id , 'material' , '' , ',' , '' );
272
+            echo is_string( $terms ) ? $terms : '—';
273
+            break;
274
+    }
275
+}
276
+
277
+// Add the custom columns for PUBLICATION:
278
+add_filter( 'manage_publication_posts_columns', 'set_custom_edit_publication_columns' );
279
+function set_custom_edit_publication_columns($columns) {
280
+    $date = $columns['date'];
281
+    unset( $columns['date'] );
282
+    $columns['material'] = __('Material');
283
+    $columns['date'] = $date;
284
+    return $columns;
285
+}
286
+// Add the data to the custom columns for PUBLICATION:
287
+add_action( 'manage_guide_posts_custom_column' , 'custom_publication_column', 10, 2 );
288
+function custom_publication_column( $column, $post_id ) {
289
+    switch ( $column ) {
290
+        case 'material' :
291
+            $terms = get_the_term_list( $post_id , 'material' , '' , ',' , '' );
292
+            echo is_string( $terms ) ? $terms : '—';
293
+            break;
294
+    }
295
+}
296
+
297
+// Add the custom columns for TECHNIQUE:
298
+add_filter( 'manage_technique_posts_columns', 'set_custom_edit_technique_columns' );
299
+function set_custom_edit_technique_columns($columns) {
300
+    $date = $columns['date'];
301
+    unset( $columns['date'] );
302
+    $columns['material'] = __('Material');
303
+    $columns['date'] = $date;
304
+    return $columns;
305
+}
306
+// Add the data to the custom columns for TECHNIQUE:
307
+add_action( 'manage_technique_posts_custom_column' , 'custom_technique_column', 10, 2 );
308
+function custom_technique_column( $column, $post_id ) {
309
+    switch ( $column ) {
310
+        case 'material' :
311
+            $terms = get_the_term_list( $post_id , 'material' , '' , ',' , '' );
312
+            echo is_string( $terms ) ? $terms : '—';
313
+            break;
314
+    }
315
+}
316
+
317
+
318
+
319
+
320
+

Chargement…
Annuler
Enregistrer