Title: get taxonomy term using sql query
Last modified: January 2, 2018

---

# get taxonomy term using sql query

 *  [mansichapter247](https://wordpress.org/support/users/mansichapter247/)
 * (@mansichapter247)
 * [8 years, 5 months ago](https://wordpress.org/support/topic/get-taxonomy-term-using-sql-query/)
 * I am having Multilingual site having English and a Hebrew site
    I am retriving
   Taxonomy term using this query SELECT DISTINCT wt.term_id , wt.name FROM wp_terms
   wt INNER JOIN wp_term_taxonomy wtt ON(wt.term_id = wtt.term_id) INNER JOIN wp_term_relationships
   pll_tr ON (pll_tr.term_taxonomy_id = wtt.term_taxonomy_id) where wtt.taxonomy
   =\’listing_category\’ AND (wt.name LIKE \’%’.$search_term.’%\’ OR wtt.description
   LIKE \’%’.$search_term.’%\’)’
 * I am only getting English terms how to combine it with polylang to get Hebrew
   terms on Hebrew site .There is no entry in wp_termmeta. Pls help

Viewing 6 replies - 1 through 6 (of 6 total)

 *  [radjan54](https://wordpress.org/support/users/radjan54/)
 * (@radjan54)
 * [8 years, 5 months ago](https://wordpress.org/support/topic/get-taxonomy-term-using-sql-query/#post-9826498)
 * Hello,
 * **pll_get_term_language($dataTag[‘term_id’])** == pll_current_language()
 * I based my queries on this field to collect data with the current language…
 *  Thread Starter [mansichapter247](https://wordpress.org/support/users/mansichapter247/)
 * (@mansichapter247)
 * [8 years, 5 months ago](https://wordpress.org/support/topic/get-taxonomy-term-using-sql-query/#post-9826671)
 * How can i use it in the above query posted to get terms for both my sites in 
   there respective languages?
 *  [radjan54](https://wordpress.org/support/users/radjan54/)
 * (@radjan54)
 * [8 years, 5 months ago](https://wordpress.org/support/topic/get-taxonomy-term-using-sql-query/#post-9826713)
 * Use those fields within the while read loop, pll_get_term_language($dataTag[‘
   term_id’]) will give you the language of the item, so process or reject…
 *  Thread Starter [mansichapter247](https://wordpress.org/support/users/mansichapter247/)
 * (@mansichapter247)
 * [8 years, 5 months ago](https://wordpress.org/support/topic/get-taxonomy-term-using-sql-query/#post-9826957)
 * Great.. Thanks for this solution . Now the issue coming is echo get_term_link(
   $t->term_id,’listing_category’) is not working .
    -  This reply was modified 8 years, 5 months ago by [mansichapter247](https://wordpress.org/support/users/mansichapter247/).
 *  [radjan54](https://wordpress.org/support/users/radjan54/)
 * (@radjan54)
 * [8 years, 5 months ago](https://wordpress.org/support/topic/get-taxonomy-term-using-sql-query/#post-9826997)
 * [https://forums.envato.com/t/can-anyone-help-me-with-wordpresss-get-term-link/75895](https://forums.envato.com/t/can-anyone-help-me-with-wordpresss-get-term-link/75895)
 *  Thread Starter [mansichapter247](https://wordpress.org/support/users/mansichapter247/)
 * (@mansichapter247)
 * [8 years, 5 months ago](https://wordpress.org/support/topic/get-taxonomy-term-using-sql-query/#post-9827153)
 * I have followed the link and also used name But when i run this qry and code ,
   it gives error .
 * $qry =’SELECT DISTINCT wt.term_id , wt.name FROM wp_terms wt INNER JOIN wp_term_taxonomy
   wtt ON(wt.term_id = wtt.term_id) INNER JOIN wp_term_relationships pll_tr ON (
   pll_tr.term_taxonomy_id = wtt.term_taxonomy_id) where wtt.taxonomy=\’listing_category\”;
 * $txnterms_listing = $wpdb->get_results($qry, OBJECT);
    foreach ($txnterms_listing
   as $t) { if(pll_get_term_language($t->term_id) == pll_current_language()):
    - 
    -  endif;
       }
 *  -  This reply was modified 8 years, 5 months ago by [mansichapter247](https://wordpress.org/support/users/mansichapter247/).

Viewing 6 replies - 1 through 6 (of 6 total)

The topic ‘get taxonomy term using sql query’ is closed to new replies.

 * ![](https://ps.w.org/polylang/assets/icon-256x256.png?rev=3433336)
 * [Polylang](https://wordpress.org/plugins/polylang/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/polylang/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/polylang/)
 * [Active Topics](https://wordpress.org/support/plugin/polylang/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/polylang/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/polylang/reviews/)

 * 6 replies
 * 2 participants
 * Last reply from: [mansichapter247](https://wordpress.org/support/users/mansichapter247/)
 * Last activity: [8 years, 5 months ago](https://wordpress.org/support/topic/get-taxonomy-term-using-sql-query/#post-9827153)
 * Status: not resolved