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 Jan 15th, 2013  |  syntax: PHP  |  size: 1.13 KB  |  views: 52  |  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. /**
  2.          * Modify the author query posts SQL to include posts co-authored
  3.          */
  4.         function posts_join_filter($join, $query) {
  5.                 global $wpdb;
  6.  
  7.                 if ($query->is_author()) {
  8.  
  9.                         if (!empty($query->query_vars['post_type']) && !is_object_in_taxonomy(
  10.                                 $query->query_vars['post_type'], $this->coauthor_taxonomy
  11.                         )
  12.                         )
  13.                                 return $join;
  14.  
  15.                         // Check to see that JOIN hasn't already been added. Props michaelingp and nbaxley
  16.                         $term_relationship_join = " INNER JOIN {$wpdb->term_relationships} ON ({$wpdb->posts}.ID = {$wpdb->term_relationships}.object_id)";
  17.                         $term_taxonomy_join = " INNER JOIN {$wpdb->term_taxonomy} ON ( {$wpdb->term_relationships}.term_taxonomy_id = {$wpdb->term_taxonomy}.term_taxonomy_id )";
  18.  
  19.                         if ($join) {
  20.                                 if (strpos($join, trim($term_relationship_join)) === false) {
  21.                                         $join .= str_replace("INNER JOIN", "LEFT JOIN", $term_relationship_join);
  22.                                 }
  23.                                 if (strpos($join, trim($term_taxonomy_join)) === false) {
  24.                                         $join .= str_replace("INNER JOIN", "LEFT JOIN", $term_taxonomy_join);
  25.                                 }
  26.                         } else {
  27.                                 $join = $term_relationship_join . $term_taxonomy_join;
  28.                         }
  29.                 }
  30.  
  31.                 return $join;
  32.         }