Convert Normal PHP form to CF7 Form
-
Hi, I have a form that is printing checkboxes, what I need is I need to map the options of a checkbox as the $post_title variable, that’s it,
so the output should be :
✓ post1
✓post2
✓post 3
etc
Here is my current code :
// Fetch published 'checklist' posts function checklist_fetch_posts() { $args = array( 'post_type' => 'checklist', 'post_status' => 'publish', 'posts_per_page' => -1, // Retrieve all posts ); $checklist_posts = new WP_Query($args); echo '<form method="post" action="process_form.php">'; if ($checklist_posts->have_posts()) { while ($checklist_posts->have_posts()) { $checklist_posts->the_post(); // Access post data here $post_title = get_the_title(); // $post_content = get_the_content(); // Output the post information as desired // echo '<h2>' . $post_title . '</h2>'; echo '<label> <input type="checkbox" name="' . $post_title . '" value="' . $post_title . '"> ' . $post_title . ' </label><br>'; } echo '<input type="submit" name="submit" value="Submit">'; // Restore original post data wp_reset_postdata(); } else { // No posts found echo 'No checklists found.'; } echo '</form>'; }Thanks,
let me know if any detail needed
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
The topic ‘Convert Normal PHP form to CF7 Form’ is closed to new replies.