I want to add “topic’s thumbnail field” in new topic post
-
I want to add topic’s thumbnail filed to specify the image file of the thumbnail of the topic in the topic creation item.
But i can’t.
Even if I specify an image file, only the name of the file is output, and maybe the image itself cannot be saved.
I added this code in “functions.php”.
If I make a mistake, Please let me know.add_action ( 'bbp_theme_before_topic_form_content', 'bbp_extra_fields'); function bbp_extra_fields() { $value = get_post_meta( bbp_get_topic_id(), 'bbp_extra_field1', true); echo '<label for="bbp_extra_field1">URL</label><br>'; echo "<input type='url' name='bbp_extra_field1' value='".$value."'>"; $value = get_post_meta( bbp_get_topic_id(), 'bbp_extra_field2', true); echo '<label for="bbp_extra_field1">pic</label><br>'; echo "<input type='file' name='bbp_extra_field2' value='".$value."'>"; } 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['bbp_extra_field1']!='') update_post_meta( $topic_id, 'bbp_extra_field1', $_POST['bbp_extra_field1'] ); if (isset($_POST) && $_POST['bbp_extra_field1']!='') update_post_meta( $topic_id, 'bbp_extra_field1', $_POST['bbp_extra_field2'] ); } add_action('bbp_template_before_replies_loop', 'bbp_show_extra_fields'); function bbp_show_extra_fields() { $topic_id = bbp_get_topic_id(); $value1 = get_post_meta( $topic_id, 'bbp_extra_field1', true); $value2 = get_post_meta( $topic_id, 'bbp_extra_field2', true); echo "Field 1: ".$value1."<br>"; echo "Field 2: ".$value2."<br>"; }
This is the error I am facing!
Viewing 13 replies - 1 through 13 (of 13 total)
Viewing 13 replies - 1 through 13 (of 13 total)
- You must be logged in to reply to this topic.