Title: Dynamic post display selection
Last modified: August 19, 2016

---

# Dynamic post display selection

 *  [challis](https://wordpress.org/support/users/challis/)
 * (@challis)
 * [17 years, 4 months ago](https://wordpress.org/support/topic/dynamic-post-display-selection/)
 * Hi there,
 * I’m looking to create a form that’ll let users select from check boxes what categories
   they want the posts that will be displayed to come from, then have a button that’ll
   submit it and process the wp_query loop with a new variable that has been created
   based upon the selection. So far, I’ve got the code to get the right files, but
   can’t find a way to do it dynamically, or string the variables togther and seperate
   them with commas. The checkboxes will each relate to a category ID. Anyway, here
   is the code:
 *     ```
       <?php $count="1" ?>
       <?php
       query_posts(array('category__and' => array($count)));
       ?>
   
       <?php if (have_posts()) : ?>
       <?php while (have_posts()) : the_post(); ?>
       <div class="topPost">
   
         <h2 class="topTitle"><a href="<?php the_permalink() ?>"><?php the_title(); ?></a></h2>
       <?php the_content(); ?>
       <span class="topMore"><a href="<?php the_permalink() ?>">more...</a></span>
       <div class="cleared"></div>
       </div> <!-- Closes topPost --><br />
   
       <?php endwhile; ?>
   
       <?php else : ?>
   
       <div class="topPost">
         <h2 class="topTitle"><a href="<?php the_permalink() ?>">Not Found</a></h2>
         <div class="topContent"><p>Sorry, but you are looking for something that isn't here. You can search again by using <a href="#searchform">this form</a>...</p></div>
       </div> <!-- Closes topPost -->
   
       <?php endif; ?>
       ```
   
 * Any help would be greatly appeciated. Been after this for a while actually, think
   it could really benifit a lotta people.
 * Cheers,
 * Challis

The topic ‘Dynamic post display selection’ is closed to new replies.

## Tags

 * [filter](https://wordpress.org/support/topic-tag/filter/)
 * [filtering](https://wordpress.org/support/topic-tag/filtering/)
 * [list](https://wordpress.org/support/topic-tag/list/)
 * [post](https://wordpress.org/support/topic-tag/post/)
 * [posts](https://wordpress.org/support/topic-tag/posts/)
 * [seach](https://wordpress.org/support/topic-tag/seach/)
 * [wp_query](https://wordpress.org/support/topic-tag/wp_query/)

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 0 replies
 * 1 participant
 * Last reply from: [challis](https://wordpress.org/support/users/challis/)
 * Last activity: [17 years, 4 months ago](https://wordpress.org/support/topic/dynamic-post-display-selection/)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
