ユーザーがタグを登録する方法
-
プラグイン「BBpress」でユーザーがトピックを作るとき、次のコードによって「カスタムフィールドとして登録すること」ができました。
これを「タグとして登録すること」はできませんでしょうか?
【カスタムフィールドの出力テンプレート】
kiji.phpecho get_post_meta(bbp_get_topic_id(), 'a', true); echo get_post_meta(bbp_get_topic_id(), 'b', true); echo get_post_meta(bbp_get_topic_id(), 'c', true); //同様に「d、e、f、g、、」と100個
【カスタムフィールドの入力と登録】
functions.phpadd_action ( 'bbp_theme_before_topic_form_content', 'bbp_extra_fields'); function bbp_extra_fields() { $html = ""; $html .= '<input type="checkbox" name="a" value="a">a'; $html .= '<input type="checkbox" name="b" value="b">b'; $html .= '<input type="checkbox" name="c" value="c">c'; //同様に「d、e、f、g、、」と100個 echo $html; } add_action ( 'bbp_new_topic', 'bbp_save_extra_fields', 10, 1 ); add_action ( 'bbp_edit_topic', 'bbp_save_extra_fields', 10, 1 ); function bbp_save_extra_fields($topic_id = 0) { if (isset($_POST) && $_POST['a']!='') { update_post_meta( $topic_id, 'a', $_POST['a'] ); } if (isset($_POST) && $_POST['b']!='') { update_post_meta( $topic_id, 'b', $_POST['b'] ); } if (isset($_POST) && $_POST['c']!='') { update_post_meta( $topic_id, 'c', $_POST['c'] ); } //同様に「d、e、f、g、、」と100個 }
たとえば
update_post_meta
をupdate_post_tag
(そんなのありませんが)のようにして、タグとして登録できるようにしたいです。そのようなことは可能でしょうか。もし方法をご存知でしたらどうか教えてください。
3件の返信を表示中 - 1 - 3件目 (全3件中)
3件の返信を表示中 - 1 - 3件目 (全3件中)
- トピック「ユーザーがタグを登録する方法」には新たに返信することはできません。