Title: Select Posts from checkboxes
Last modified: August 21, 2016

---

# Select Posts from checkboxes

 *  [cheasy](https://wordpress.org/support/users/cheasy/)
 * (@cheasy)
 * [12 years, 3 months ago](https://wordpress.org/support/topic/select-posts-from-checkboxes/)
 * Hi,
 * I made a form which shows all posts of a category and these posts should be able
   to be selected by checkboxes. I found a php code here on the Support site, but
   it was ment for dropdown-Selections, which shows the titles of the posts in the
   option fields.
 * The Posts are correctly shown on my site and I’m also able to check the checkboxes,
   but when I send the form, the names don’t appear in the submitted e-mail.
 * This is the code (functions.php), that I found:
 *     ```
       wpcf7_add_shortcode('postdropdown', 'createbox', true);
       function createbox(){
       global $post;
       $args = array('numberposts' => 0, 'category' => 5 );
       $myposts = get_posts( $args );
       $output = "<select name='cursus' id='cursus' onchange='document.getElementById(\"cursus\").value=this.value;'><option></option>";
       foreach ( $myposts as $post ) : setup_postdata($post);
       	$title = get_the_title();
       	$output .= "<option value='$title'> $title </option>";
   
       	endforeach;
       $output .= "</select>";
       return $output;
       }
       ```
   
 * and this is my Version:
 *     ```
       <?php wpcf7_add_shortcode('postdropdown', 'createbox', true);
       function createbox(){
       global $post;
       $args = array('numberposts' => 0, 'category' => 3 );
       $myposts = get_posts( $args );
       $output = '<table id="mietwohnungen">
          <tr>
           <th>&nbsp; </th>
           <th width="150">Ort</th>
           <th width="150">Fotos</th>
           <th width="360">Beschreibung</th>
           <th width="100">Gr&ouml;sse</th>
           <th>Euro</th>
          </tr>';
       foreach ( $myposts as $post ) : setup_postdata($post);
       	$content = get_the_content();
       	$title = get_the_title();
       	$ort = get_post_meta($post->ID, 'Ort', true);
       	$groesse = get_post_meta($post->ID, 'Größe', true);
       	$Kaufpreis = get_post_meta($post->ID, 'Kaufpreis', true);
       	$output .= "<tr><td> <input type='checkbox' name='$title' /> </td>
       				 <td>$ort</td>
       				 <td colspan='2'>$content</td>
       				 <td>$groesse</td>
       				 <td>$Kaufpreis</td>
       	  			</tr>";
   
       	endforeach;
       return $output;
       $output .= '</table>';
       } ?>
       ```
   
 * I put the shortcode [postdropdown mietwohnungen] in the contact form and [mietwohnungen]
   in the mailtemplate.
 * I’m spending hours in solving this special problem, but I still can’t get it 
   fixed, unfortunately I’m no PHP expert.
 * Thanks,
    Christiane
 * [http://wordpress.org/plugins/contact-form-7/](http://wordpress.org/plugins/contact-form-7/)

The topic ‘Select Posts from checkboxes’ is closed to new replies.

 * ![](https://ps.w.org/contact-form-7/assets/icon.svg?rev=2339255)
 * [Contact Form 7](https://wordpress.org/plugins/contact-form-7/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/contact-form-7/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/contact-form-7/)
 * [Active Topics](https://wordpress.org/support/plugin/contact-form-7/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/contact-form-7/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/contact-form-7/reviews/)

## Tags

 * [contact](https://wordpress.org/support/topic-tag/contact/)
 * [database](https://wordpress.org/support/topic-tag/database/)
 * [form](https://wordpress.org/support/topic-tag/form/)
 * [php](https://wordpress.org/support/topic-tag/php/)
 * [posts](https://wordpress.org/support/topic-tag/posts/)

 * 0 replies
 * 1 participant
 * Last reply from: [cheasy](https://wordpress.org/support/users/cheasy/)
 * Last activity: [12 years, 3 months ago](https://wordpress.org/support/topic/select-posts-from-checkboxes/)
 * Status: not resolved