Pastebin launched a little side project called VERYVIRAL.com, check it out ;-) Want more features on Pastebin? Sign Up, it's FREE!
Guest

Untitled

By: a guest on Sep 12th, 2012  |  syntax: PHP  |  size: 0.92 KB  |  views: 34  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  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. ?>