-
Notifications
You must be signed in to change notification settings - Fork 112
/
books-post-type.php
50 lines (31 loc) · 1015 Bytes
/
books-post-type.php
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
<?php
// include the custom post type class
include_once('CPT.php');
// create a book custom post type
$books = new CPT('book');
// create a genre taxonomy
$books->register_taxonomy('genre');
// define the columns to appear on the admin edit screen
$books->columns(array(
'cb' => '<input type="checkbox" />',
'title' => __('Title'),
'genre' => __('Genres'),
'price' => __('Price'),
'rating' => __('Rating'),
'date' => __('Date')
));
// populate the price column
$books->populate_column('price', function($column, $post) {
echo "£" . get_field('price'); // ACF get_field() function
});
// populate the ratings column
$books->populate_column('rating', function($column, $post) {
echo get_field('rating') . '/5'; // ACF get_field() function
});
// make rating and price columns sortable
$books->sortable(array(
'price' => array('price', true),
'rating' => array('rating', true)
));
// use "pages" icon for post type
$books->menu_icon("dashicons-book-alt");