質問編集履歴
2
マークアップ
test
CHANGED
File without changes
|
test
CHANGED
@@ -21,6 +21,8 @@
|
|
21
21
|
|
22
22
|
|
23
23
|
[ ver1.1 ]
|
24
|
+
|
25
|
+
```php
|
24
26
|
|
25
27
|
add_action( 'publish_ABC', 'function_copying_posts', 10);
|
26
28
|
|
@@ -78,13 +80,13 @@
|
|
78
80
|
|
79
81
|
} } }
|
80
82
|
|
81
|
-
|
82
|
-
|
83
|
-
|
83
|
+
```
|
84
84
|
|
85
85
|
|
86
86
|
|
87
87
|
[ ver1.2 ]
|
88
|
+
|
89
|
+
```php
|
88
90
|
|
89
91
|
add_action('save_post_ABC', 'function_copying_posts', 10, 3);
|
90
92
|
|
@@ -150,7 +152,7 @@
|
|
150
152
|
|
151
153
|
}
|
152
154
|
|
153
|
-
|
155
|
+
```
|
154
156
|
|
155
157
|
|
156
158
|
|
1
ソースコードの修正
test
CHANGED
File without changes
|
test
CHANGED
@@ -19,6 +19,8 @@
|
|
19
19
|
### 該当のソースコード
|
20
20
|
|
21
21
|
|
22
|
+
|
23
|
+
[ ver1.1 ]
|
22
24
|
|
23
25
|
add_action( 'publish_ABC', 'function_copying_posts', 10);
|
24
26
|
|
@@ -78,6 +80,78 @@
|
|
78
80
|
|
79
81
|
|
80
82
|
|
83
|
+
---------------------------------------------------------
|
84
|
+
|
85
|
+
|
86
|
+
|
87
|
+
[ ver1.2 ]
|
88
|
+
|
89
|
+
add_action('save_post_ABC', 'function_copying_posts', 10, 3);
|
90
|
+
|
91
|
+
function function_copying_posts($post_id, $post, $update) {
|
92
|
+
|
93
|
+
if (wp_is_post_revision($post_id)) return; // 自動保存を除外
|
94
|
+
|
95
|
+
|
96
|
+
|
97
|
+
remove_action('save_post_ABC', 'function_copying_posts'); // 無限ループ対策
|
98
|
+
|
99
|
+
|
100
|
+
|
101
|
+
// 投稿タイプ「ABC」から情報を取得
|
102
|
+
|
103
|
+
$taxonomy_check = get_field('taxonomy_check', $post_id); //タクソノミーチェックボックス
|
104
|
+
|
105
|
+
$check[] = '';
|
106
|
+
|
107
|
+
foreach($taxonomy_check as $term){
|
108
|
+
|
109
|
+
array_push($check, $term->name);
|
110
|
+
|
111
|
+
}
|
112
|
+
|
113
|
+
$text = get_field('text', $post_id); //テキストエリア
|
114
|
+
|
115
|
+
$copy = get_field('copy', $post_id);
|
116
|
+
|
117
|
+
$catch_copy = $copy['catch_copy']; //グループ「copy」のサブフィールド1
|
118
|
+
|
119
|
+
$lead_copy = $copy['lead_copy']; //グループ「copy」のサブフィールド2
|
120
|
+
|
121
|
+
|
122
|
+
|
123
|
+
// 投稿先の指定
|
124
|
+
|
125
|
+
$draft_my_options = array(
|
126
|
+
|
127
|
+
'post_title' => get_the_title($post_id),
|
128
|
+
|
129
|
+
'post_status' => get_post_status($post_id),
|
130
|
+
|
131
|
+
'post_type' => 'DEF'
|
132
|
+
|
133
|
+
);
|
134
|
+
|
135
|
+
$newpost_id = wp_insert_post($draft_my_options);
|
136
|
+
|
137
|
+
|
138
|
+
|
139
|
+
update_post_meta($newpost_id, 'text', $text);
|
140
|
+
|
141
|
+
update_post_meta($newpost_id, 'catch_copy', $catch_copy);
|
142
|
+
|
143
|
+
update_post_meta($newpost_id, 'lead_copy', $lead_copy);
|
144
|
+
|
145
|
+
wp_set_object_terms($newpost_id, $check, 'com_check', false);
|
146
|
+
|
147
|
+
|
148
|
+
|
149
|
+
add_action( 'save_post_ABC', 'function_copying_posts'); // 無限ループ対策
|
150
|
+
|
151
|
+
}
|
152
|
+
|
153
|
+
|
154
|
+
|
81
155
|
|
82
156
|
|
83
157
|
### 試したこと
|