• Resolved Overflow

    (@acrane)


    I want to generate a list of Custom Taxonomy terms, 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()

Viewing 1 replies (of 1 total)
  • Thread Starter Overflow

    (@acrane)

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

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

    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>';
    }
Viewing 1 replies (of 1 total)
  • The topic ‘Search Taxonomy terms not posts’ is closed to new replies.