質問編集履歴

4

var_dump削除

2017/10/10 14:10

投稿

退会済みユーザー
test CHANGED
File without changes
test CHANGED
@@ -72,8 +72,6 @@
72
72
 
73
73
  $post_meta = get_post_meta($post_id, 'publish_type', true);
74
74
 
75
- vd($post_meta);
76
-
77
75
  if ($post_meta == 'free') {
78
76
 
79
77
  echo '無';

3

投稿一覧に項目を追加と投稿一覧に追加した項目に値を表示追加

2017/10/10 14:10

投稿

退会済みユーザー
test CHANGED
File without changes
test CHANGED
@@ -30,8 +30,84 @@
30
30
 
31
31
 
32
32
 
33
+
34
+
35
+
36
+
33
37
  ```ここに言語を入力
34
38
 
39
+
40
+
41
+
42
+
43
+ /**
44
+
45
+ * 投稿一覧に項目を追加する
46
+
47
+ */
48
+
49
+ function my_posts_columns($defaults) {
50
+
51
+ $defaults['publish_type'] = '状況';
52
+
53
+ return $defaults;
54
+
55
+ }
56
+
57
+
58
+
59
+ add_filter('manage_posts_columns', 'my_posts_columns');
60
+
61
+ /**
62
+
63
+ * 投稿一覧に追加した項目に値を表示する
64
+
65
+ */
66
+
67
+ function my_posts_custom_column($column, $post_id) {
68
+
69
+ switch ($column) {
70
+
71
+ case 'publish_type':
72
+
73
+ $post_meta = get_post_meta($post_id, 'publish_type', true);
74
+
75
+ vd($post_meta);
76
+
77
+ if ($post_meta == 'free') {
78
+
79
+ echo '無';
80
+
81
+ } elseif ($post_meta == 'premium') {
82
+
83
+ echo '有';
84
+
85
+ } else {
86
+
87
+ echo '';
88
+
89
+ }
90
+
91
+ break;
92
+
93
+ case 'display':
94
+
95
+ }
96
+
97
+ }
98
+
99
+
100
+
101
+ add_action('manage_posts_custom_column', 'my_posts_custom_column', 10, 2);
102
+
103
+
104
+
105
+
106
+
107
+
108
+
109
+
110
+
35
111
  //クイック編集にカスタムフィールド(掲載状況)の入力フォームを表示
36
112
 
37
113
  function display_my_custom_quickedit($column_name, $post_type) {

2

参考サイト 追加

2017/10/10 11:02

投稿

退会済みユーザー
test CHANGED
File without changes
test CHANGED
@@ -10,6 +10,12 @@
10
10
 
11
11
 
12
12
 
13
+ 参考サイト https://increment-log.com/quickedit-custom-field/
14
+
15
+
16
+
17
+
18
+
13
19
  カスタムフィールド名
14
20
 
15
21
  publish_type

1

初心者アイコン表示

2017/10/10 07:47

投稿

退会済みユーザー
test CHANGED
File without changes
test CHANGED
File without changes