Forum Moderators: coopster
The post-form allows them to type in keyword tags (which then get displayed within their published post as links, which when clicked, show a page with all posts sharing the same tag).
I want to have checkboxes for specific tags in the post-form.
The tags text input field in post-form.php looks like this:
<label for="post_tags"><?php _e('Tags','cp'); ?> <small><?php _e('(separate with commas)','cp'); ?></small></label>
<input type="text" id="post_tags" class="adfields" name="post_tags" size="60" maxlength="100" value="<?php echo $_POST['post_tags']; ?>" />
I noticed the form_process.php contains this:
$post_tags = cp_filter($_POST['post_tags']);
and this also in form_process.php:
$post_id = wp_insert_post( array(
'post_author'=> $user_id,
'post_title'=> $post_title,
'post_content'=> $description,
'post_category'=> $post_cat_array,
'post_status'=> $post_status,
'tags_input'=> $post_tags
I have tried adding this to post-form.php:
<label for="post_tags"><?php _e('Tags ','cp'); ?></label>
<input type="checkbox" name="post_tags" value="Monday" />Monday<br />
<input type="checkbox" name="post_tags" value="Tuesday" />Tuesday<br />
Now when Monday and Tuesday are both checked, only the lower one (Tuesday) gets associated with the post (and anything typed into the tags text field is not associated with the post).
I'm nearing a dozen hours reading about how I need to set this up as an array (name="post_tags[]") but I'm still not sure how to go about it, especially in form_process.php
Any help is appreciated.
In form_process.php I have this:
$checkbox_tags= ($_POST['checkbox_tags']);
------------------
And in post-form.php I have this:
<input type="checkbox" name="checkbox_tags[]" value="Wednesday" />Wednesday<br />
<input type="checkbox" name="checkbox_tags[]" value="Thursday" />Thursday<br />
<input type="checkbox" name="checkbox_tags[]" value="Friday" />Friday<br />
--------------------
I see now that the following part of form_process.php is what makes the tags be associated with the post:
'tags_input'=> $checkbox_tags
------------------------------
Btw, what is the name for this arrow made with an equals sign: =>
Also, how can I get 'tags_input' to include both $checkbox_tags, and also $post_tags ? As this will allow me to have the checkbox tags pooled with the tags entered into the text field.