• Hi,

    I’m not sure why this is happening but, the query below keeps returning no results when I DO have an element’s term_group set to 2 in wp_terms.

    To troubleshoot, I replaced the term_group condition by a slug condition (i.e. t.slug = chicago) and that worked fine…

    So, I’m very puzzled… Thanks to anyone who can help!

    global $wpdb;
    $query = "SELECT
    		taxo.*,
    		t.*
    	FROM
    		$wpdb->term_taxonomy taxo,
    		$wpdb->terms t
    	WHERE
    		taxo.term_id = t.term_id AND
    		taxo.taxonomy = 'post_tag' AND
    		t.term_group = 2
    	ORDER BY count DESC
    	LIMIT 10";
    
    	$companies = $wpdb->get_results($query);
  • The topic ‘Issue with term_group when running $wpdb query’ is closed to new replies.