I want to generate a list of Custom Taxonomy terms, searching through the searchform. I don't need to return posts associated the the term, I want to return the terms themselves that will link to get_term_link()



Use get_terms() to retrieve terms that match your search query like :

$termsResult = get_terms( 'CUSTOM_TAXONOMY_NAME', 'search=SEARCH_QUERY' );


CUSTOM_TAXONOMY_NAME is your custom taxonomy and SEARCH_QUERY is the string which you are using to search for terms.

Afterwards you can generate list like :

if ( ! empty( $termsResult ) && ! is_wp_error( $termsResult ) ){
  echo '<ul>';
    foreach ( $termsResult as $term ) {
      echo '<li><a href="'.get_term_link( $term ).'">' . $term->name . '</a></li>';
  echo '</ul>';
  • Gah!! I can't believe it was that easy! I couldn't find much about this anywhere out there. Thanks so much.
    – acrane
    Dec 4 '14 at 20:57

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.