• 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.