SHARE
TWEET

Untitled

a guest Sep 12th, 2012 40 Never
  1. <?php
  2. global $query_string;
  3. $my_query_string = $query_string;
  4. $catnames = array('post-format-aside','post-format-link','post-format-gallery','post-format-status','post-format-quote','post-format-image');
  5. //using implode to generate the list of formats ids comma-separated
  6. $catnames[0] = "-".$catnames[0];
  7. $format_id_list_to_exclude = implode(",-",$catnames);
  8. $catnames[0] = substr('$catnames[0]', 1);
  9. $format_id_list = implode(",",$catnames);
  10. //query posts excluding posts that have formats:
  11. $myquery = new WP_Query ($my_query_string . "&cat=$format_id_list_to_exclude");
  12.         if ($myquery->have_posts()) :
  13.                 while ($myquery->have_posts()) : $myquery->the_post();
  14.                 //display non-formated posts
  15.                 endwhile;
  16.         endif;
  17. $myquery = new WP_Query ($my_query_string . "&cat=$format_id_list");
  18. if ($myquery->have_posts()) :
  19.                 while ($myquery->have_posts()) : $myquery->the_post();
  20.                 //display non-formated posts
  21.                 endwhile;
  22.         endif;
  23.  
  24. ?>
RAW Paste Data
Top