質問編集履歴

1

フォームを追記

2017/09/18 11:21

投稿

kurosuke___
kurosuke___

スコア217

test CHANGED
File without changes
test CHANGED
@@ -6,7 +6,35 @@
6
6
 
7
7
  ```PHP
8
8
 
9
+ if($_POST["req"] == "send_content"):
10
+
9
11
  $wpdb->query($wpdb->prepare("UPDATE $wpdb->tag_content SET `title`=%s, `content`=%s WHERE `term_id`=%d", $_POST["title"], $_POST["tag_content_editor"], $_POST["term_id"]));
12
+
13
+ ```
14
+
15
+
16
+
17
+ フォームはこんな感じで、`wp_editor()`でwordpressのリッチテキストエディタを呼び出しています。
18
+
19
+ tag_content_editorというのがコンテンツになります。
20
+
21
+ ```PHP
22
+
23
+ <form action="現在のページ" method="post">
24
+
25
+ <input type="hidden" name="req" value="send_content">
26
+
27
+ <input type="hidden" name="term_id" value="<?php echo $tag->term_id; ?>">
28
+
29
+ <label for="title">タイトル</label>
30
+
31
+ <input type="text" name="title"><br>
32
+
33
+ <?php wp_editor($content, "tag_content_editor"); ?>
34
+
35
+ <input type="submit" value="更新">
36
+
37
+ </form>
10
38
 
11
39
  ```
12
40