lundi 20 avril 2015

WordPress - If Category selected = ?, display?

Currently, I am displaying all of my posts in a list, which works fine, as below:

    <div class="container">
  <div class="row" style="margin-top:20px;">
    <?php 
    $args = new WP_Query();
    $loop = new WP_Query( $args );
    while ($loop->have_posts() ) : $loop->the_post();
    ?>
    <div class="col-md-8 col-sm-12 col-xs-12">
      <div class="postsize">
      <div style="float: left; padding-right:20px;">
        <?php echo get_the_post_thumbnail( $page->ID, 'categoryimage', array('class' => 'faqposts')); ?>
      </div>
      <h5 class="captext"><?php the_title(); ?></h5>
      <span class="entry-date-orange"><?php echo get_the_date(); ?></span>
      <p style="margin-top:10px";><?php the_excerpt(); ?></p>
    </div>
  </div>
  <?php endwhile; ?>
  <?php wp_reset_query(); ?> 


</div>
</div>

What I need, is options on the right hand side, which shows all my post categories. Once a post category is selected, the list of posts is recalculated and displays only the posts from the selected categories.

So for example, I would have the below layout:

POST CATEGORY LIST

POST

POST

POST

POST

POST

And once a selected post category is selected, the list on the right changes.

Any ideas? Thank you.

Aucun commentaire:

Enregistrer un commentaire