• Hello,
    I’m implementing an additional filter on the author page, that if is set, filter the posts on a custom taxomy. I’m doing this using a pre_get_posts and setting tax_query accordingly.

    // A custom query var for the author page
    function multi_tags( $query ) {
    	$m_tag = $_GET['m_tag'];
    
        if ( $query->is_author() && !empty($m_tag) && $query->is_main_query()) {
    		$taxquery = array(
    	        array(
    	            'taxonomy' => 'multi-tag',
    	            'field' => 'id',
    	            'terms' => array(259),
    	        )
    	    );
    		    $query->set( 'tax_query', $taxquery );
        }
    	}
    add_action( 'pre_get_posts', 'multi_tags' );

    Unfortunatly this wasn’t working, because I was getting the following SQL error:
    Not unique table/alias: 'wp_term_relationships'
    The point was that my tax_query was adding a JOIN that co authors already added. I found that in your code there’s already implemented a control against a JOIN (circa row 614 of co-authors-plus.php), but that control check for an INNER JOIN.
    In order to solve my problem I had to check against LEFT JOIN, instead.

    Probably that piece of code need to be revised. I’m avaialable if you need further details.

    Thank you,

    • This topic was modified 8 years, 3 months ago by llago.
    • This topic was modified 8 years, 3 months ago by llago.
  • The topic ‘Check for an already existing JOIN could be buggy’ is closed to new replies.