Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /**
- * Modify the author query posts SQL to include posts co-authored
- */
- function posts_join_filter($join, $query) {
- global $wpdb;
- if ($query->is_author()) {
- if (!empty($query->query_vars['post_type']) && !is_object_in_taxonomy(
- $query->query_vars['post_type'], $this->coauthor_taxonomy
- )
- )
- return $join;
- // Check to see that JOIN hasn't already been added. Props michaelingp and nbaxley
- $term_relationship_join = " INNER JOIN {$wpdb->term_relationships} ON ({$wpdb->posts}.ID = {$wpdb->term_relationships}.object_id)";
- $term_taxonomy_join = " INNER JOIN {$wpdb->term_taxonomy} ON ( {$wpdb->term_relationships}.term_taxonomy_id = {$wpdb->term_taxonomy}.term_taxonomy_id )";
- if ($join) {
- if (strpos($join, trim($term_relationship_join)) === false) {
- $join .= str_replace("INNER JOIN", "LEFT JOIN", $term_relationship_join);
- }
- if (strpos($join, trim($term_taxonomy_join)) === false) {
- $join .= str_replace("INNER JOIN", "LEFT JOIN", $term_taxonomy_join);
- }
- } else {
- $join = $term_relationship_join . $term_taxonomy_join;
- }
- }
- return $join;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement