michaelM
Fils de soutien créés au cours des 30 derniers jours : 0
Sujets de forum favoris
Cet utilisateur n'a aucun sujet favori.
Sujets de forum créés
Status | Sujet | Supporter | Voix | Publications | Nouveauté |
---|---|---|---|---|---|
Filter for posts that have a specific taxonomy term ONLY and not any other
Commencé par : michaelM
dans : Toolset Professional Support
Problem: I would like to set up a View that filters results based on two separate hierarchical taxonomies. I want to specify a single term from each taxonomy using a shortcode attribute in my View shortcode. I do not want to include results from the selected terms' child terms. I only want to include results that have the selected terms applied. Solution: Use shortcode attributes on your View to pass in the terms you want to filter, and create taxonomy Query Filters to respond to these shortcodes. Add the following code to functions.php: add_filter( 'wpv_filter_query', 'only_term_filter',99,3 ); function only_term_filter( $query_args, $views_settings, $view_id) { if ($view_id == 12345){ foreach($query_args['tax_query'] as $tq) { if( isset( $tq['taxonomy'] ) ){ $tax = $tq['taxonomy']; $term = get_term_by('id', $tq['terms'][0], $tax); $termChildren = get_term_children($term->term_id, $tax); $query_args['tax_query'][] = array( 'taxonomy' => $tax, 'field' => 'id', 'terms' => $termChildren, 'operator' => 'NOT IN' ); } } } return $query_args; } Modify the View ID 12345 to match your View's numeric ID. Then use the following shortcode to place the View on your site: [wpv-view name="program-by-college-type" wpvpgmcollege="healthsciences" wpvpgmtype="undergrad"] Replace the slugs as needed, or make them dynamic by replacing the values with other shortcodes. Relevant Documentation: https://toolset.com/documentation/programmer-reference/views-filters/#wpv_filter_query |
2 | 8 | Il y a 6 années et 8 mois | ||
Types 2.0.1.1 Breaks WP Native Gallery Reordering
Commencé par : michaelM dans : Toolset Professional Support |
2 | 5 | Il y a 7 années et 12 mois | ||
Types 2.0.1 Update Conflict with Visual Composer
1
2
Commencé par : michaelM dans : Toolset Professional Support |
5 | 21 | Il y a 8 années | ||
Filter Taxonomy With Shortcode Attribute and Specify NOT
Commencé par : michaelM dans : Toolset Professional Support |
2 | 6 | Il y a 8 années et 10 mois | ||
Custom Fields for Taxonomies
Commencé par : michaelM dans : Toolset Professional Support |
2 | 2 | Il y a 8 années et 10 mois |