Guest User

Untitled

a guest
Aug 10th, 2018
98
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.09 KB | None | 0 0
  1. wordpress get_terms function not working in my plugin
  2. $terms = get_terms($taxonomy , 'hide_empty=0');
  3. print_r($terms);
  4. $count = count($terms);
  5. if ( $count > 0 ){
  6. echo "<ul>";
  7. foreach ( $terms as $term ) {
  8. echo "<li>" . $term->name . "</li>";
  9.  
  10. }
  11. echo "</ul>";
  12.  
  13. WP_Error Object
  14. (
  15. [errors] => Array
  16. (
  17. [invalid_taxonomy] => Array
  18. (
  19. [0] => Invalid Taxonomy
  20. )
  21.  
  22. )
  23.  
  24. [error_data] => Array
  25. (
  26. )
  27.  
  28. )
  29.  
  30. function load_terms($taxonomy){
  31. global $wpdb;
  32. $query = 'SELECT DISTINCT
  33. t.name
  34. FROM
  35. `wp-cls`.wp_terms t
  36. INNER JOIN
  37. `wp-cls`.wp_term_taxonomy tax
  38. ON
  39. `tax`.term_id = `t`.term_id
  40. WHERE
  41. ( `tax`.taxonomy = '' . $taxonomy . '')';
  42. $result = $wpdb->get_results($query , ARRAY_A);
  43. return $result;
  44. }
Add Comment
Please, Sign In to add comment