• I am running these args through WP_Query (returned by object to verify):

    [query] => Array
            (
                [post_type] => post
                [category__in] => Array
                    (
                        [0] => 1
                    )
    
                [orderby] => date
            )

    And this is being run:

    [request] => SELECT SQL_CALC_FOUND_ROWS  wp_posts.ID FROM wp_posts  INNER JOIN wp_term_relationships ON (wp_posts.ID = wp_term_relationships.object_id)LEFT OUTER JOIN wp_term_relationships ON wp_posts.ID=wp_term_relationships.object_id
    LEFT OUTER JOIN wp_term_taxonomy USING (term_taxonomy_id)
    LEFT OUTER JOIN wp_terms USING (term_id) WHERE 1=1  AND (
      wp_term_relationships.term_taxonomy_id IN (1)
    ) AND wp_posts.post_type = 'post' AND (wp_posts.post_status = 'publish' OR wp_posts.post_status = 'private') AND (taxonomy = 'attachment_type' OR taxonomy IS NULL) GROUP BY object_id ORDER BY GROUP_CONCAT(wp_terms.name ORDER BY name ASC)  LIMIT 0, 20

    This is only happening on a custom post type archive page, and attachment_type is obviously a custom taxonomy linked to the CPT.

    This is causing an error of:

    WordPress database error: [Not unique table/alias: ‘wp_term_relationships’

Viewing 3 replies - 1 through 3 (of 3 total)
  • Something doesn’t add up, there is no way using just those query args will result in that statement, and if you are using a custom post type and a custom taxonomy, why are you using ‘post’ post type and ‘category’ taxonomy?

    Thread Starter weissmike

    (@weissmike)

    I know right!

    The query is being run as part of a widget inside of the footer area.

    Both the Query args and the Request came from the same print_r of the WP_Query object.

    Thread Starter weissmike

    (@weissmike)

    Nevermind, I found that there was a function snuck into the theme that was modifying the query.

    Thanks!
    Mike

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘WP_Query on CPT Archive Page including Custom Taxonomy’ is closed to new replies.