質問編集履歴
1
コードを追記
title
CHANGED
File without changes
|
body
CHANGED
@@ -72,4 +72,47 @@
|
|
72
72
|
この3点が解決できず、こちらに投稿をさせていただきました。
|
73
73
|
有識者の方がいらっしゃいましたら、教えていただけますと幸いです。
|
74
74
|
|
75
|
-
どうぞ宜しくお願い致します。
|
75
|
+
どうぞ宜しくお願い致します。
|
76
|
+
|
77
|
+
|
78
|
+
|
79
|
+
|
80
|
+
追記
|
81
|
+
|
82
|
+
下記コードにて自動投稿まではできました。
|
83
|
+
あとはカスタムフィールド の値によって、「自動投稿の有無を選べるようにする方法」で行き詰まっています。
|
84
|
+
|
85
|
+
|
86
|
+
```ここに言語を入力
|
87
|
+
function function_copying_posts()
|
88
|
+
{
|
89
|
+
|
90
|
+
|
91
|
+
global $post;
|
92
|
+
|
93
|
+
if ($post->post_type == 'works') {
|
94
|
+
$current_postID = $post->ID;
|
95
|
+
|
96
|
+
|
97
|
+
$hoge_name = $_POST['acf']["キー"];
|
98
|
+
$hoge_linkage = $_POST['acf']["キー"];
|
99
|
+
|
100
|
+
// 自動投稿するときのステータスをここで指定
|
101
|
+
$draft_my_options = array(
|
102
|
+
'post_title' => get_the_title($current_postID),
|
103
|
+
'post_content' => '',
|
104
|
+
'post_status' => 'publish',
|
105
|
+
'post_type' => 'news'
|
106
|
+
);
|
107
|
+
|
108
|
+
$newpost_id = wp_insert_post($draft_my_options);
|
109
|
+
|
110
|
+
if ($newpost_id) {
|
111
|
+
// カスタムフィールドに値を挿入しています。
|
112
|
+
update_post_meta($newpost_id, 'news_pic', $hoge_name);
|
113
|
+
update_post_meta($newpost_id, 'news_linkage', $hoge_linkage);
|
114
|
+
}
|
115
|
+
}
|
116
|
+
}
|
117
|
+
add_action('publish_works', 'function_copying_posts', 9);
|
118
|
+
```
|