Reputation: 39
I have this code
$ret .= '<a class="tourmaster-tour-category-head-link" href="' . esc_url(get_term_link($category->term_id, $taxonomy)) . '" >';
that print this URL
http://example.com/tour-destination/america/ or.. http://example.com/tour-destination/europa/ etc..
How to keep only taxonomy slug (example: "america" ) from this url?
My goal is to replace this function and create a search url, something like this one:
$ret .= '<a class="tourmaster-tour-category-head-link" href="http://example.com/search-tours/?tour-search=&tax-tour-destination= ' . esc_url(get_term_link($category->term_id, $taxonomy)) . '" >';
to have a URL like:
http://example.com/search-tours/?tour-search=&tax-tour-destination=america
How to make this possible?
Upvotes: 0
Views: 339
Reputation: 830
You already should have it in your $category object. Assuming that is actually a $term; If you not you can easily get it.
$slug = $category->slug;
or
$term = get_term( $category->term_id, $taxonomy );
$slug = $term->slug;
$ret .= '<a class="tourmaster-tour-category-head-link" href="example.com/search-tours/' . $slug . '" >';
Upvotes: 1