Startseite › Toolset Professional Support › [Gelöst] Hide Taxonomy from form dropdown list via checked custom field in Taxonomy
This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.
Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.
| Sun | Mon | Tue | Wed | Thu | Fri | Sat |
|---|---|---|---|---|---|---|
| - | 9:00 – 13:00 | 9:00 – 13:00 | 9:00 – 13:00 | 9:00 – 13:00 | 9:00 – 13:00 | - |
| - | 14:00 – 18:00 | 14:00 – 18:00 | 14:00 – 18:00 | 14:00 – 18:00 | 14:00 – 18:00 | - |
Zeitzone des Unterstützers: Asia/Hong_Kong (GMT+08:00)
Dieses Thema enthält 2 Antworten, hat 2 Stimmen.
Zuletzt aktualisiert von LandruF8417 vor 3 years, 1 month.
Assistiert von: Luo Yang.
I would like to hide certain Taxonomies from search form dropdown list via a checked custom term field in Taxonomy.
I currently have the following code in View Search Filter:
<label>
[wpv-control taxonomy="attorney-practice-area" url_param="wpv-attorney-practice-area" type="select" default_label="BY PRACTICE" taxonomy_order="ASC" taxonomy_orderby="name" hide_empty="true"]
</label>
And I have a checkbox custom term field in the Practice Area taxonomy with slug "hide-from-search".
How can I hide terms that has this field checked?
Hello,
It is possible with filter hook "wpv_filter_taxonomy_frontend_search_available_terms", see below sandbox website:
Login URL: versteckter Link
1) Dashboard-> Toolset-> Settings-> Custom code:
versteckter Link
Add one item, with below codes:
add_filter( 'wpv_filter_taxonomy_frontend_search_available_terms', 'hide_terms', 10, 3 );
function hide_terms( $terms, $taxonomy, $view_id ) {
$curated_terms = array();
foreach ( $terms as $term ) {
if ( get_term_meta( $term->term_id, 'wpcf-hide-from-search', true ) != 1) {
$curated_terms[] = $term;
}
}
return $curated_terms;
}
2) Test it in frontend:
versteckter Link
It won't display the specific term "term1" in frontend
Worked Great! Thank you for the solution, Luo Yang!