-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpost_type_columns.php
66 lines (55 loc) · 1.77 KB
/
post_type_columns.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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
<?php
// Custom column Display
add_filter( 'manage_edit-wp_dental_columns', 'edit_wp_dental_columns' ) ;
function edit_wp_dental_columns( $columns ) {
$columns = array(
'nama' => __( 'Nama Pasien' ),
'alamat' => __('Alamat' ),
'telepon' => __('Telepon'),
'edit' => __('Edit')
);
return $columns;
}
// What to display in each list column
add_action( 'manage_wp_dental_posts_custom_column', 'manage_wp_dental_columns', 10, 2 );
function manage_wp_dental_columns( $column, $post_id ) {
// Get meta if exists
$nama = get_post_meta( $post_id, '_nama', true );
$alamat = get_post_meta( $post_id, '_alamat', true );
$telepon = get_post_meta( $post_id, '_telepon', true );
switch( $column ) {
case 'nama' :
if ( empty( $nama ) ) {
echo __( 'Unknown' );
} else {
echo '<a href="'; ?> <?php the_permalink(); ?> <?php echo '">' . $nama . '</a>';
}
break;
case 'alamat' :
if ( empty( $alamat ) ) {
echo __( 'Unknown' );
} else {
echo $alamat;
}
break;
case 'telepon' :
if ( empty( $telepon ) ) {
echo __( 'Unknown' );
} else {
echo $telepon;
}
break;
case 'edit' :
echo '<a href="/wp-admin/post.php?post='.$post_id.'&action=edit">EDIT</a>';
break;
}
}
// Which columns are filterable
add_filter( 'manage_edit-wp_dental_sortable_columns', 'wp_dental_sortable_columns' );
function wp_dental_sortable_columns( $columns ) {
$columns['nama'] = 'nama';
$columns['alamat'] = 'alamat';
$columns['telepon'] = 'telepon';
return $columns;
}
?>