Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //mostra i checkbox dei tag
- $mytags = get_tags
- ( array(
- 'taxonomy' => 'post_tag',
- 'hide_empty' => false, // Include empty terms as well
- 'exclude' => '442, 255, 326, 421,441', // term IDs to exclude
- ));
- global $post;
- $lang = substr( get_locale(), 0, 2);
- $locale = get_locale();
- $tags = "<span class=\"checkmark\"></span>";
- foreach ($mytags as $term){
- $checked = empty( get_query_var('tag__and')) ? '': checked( in_array( $term->term_id, get_query_var('tag__and')), true, false );
- //prova checked wi-fi
- if ( 203 == $term->term_id ) {
- empty( get_query_var('tag__in')) ? '': checked( in_array( $term->term_id, get_query_var('tag__in')), true, false );
- }
- //fine prova
- if ('it_IT' != $locale ) {
- $termine_straniero = get_term_meta($term->term_id, 'function_post_tag_'.$lang , true );
- $tags .= "<input type=\"checkbox\" $checked name=\"tag__and[]\" value=\"{$term->term_id}\">";
- $tags .= "<label class=\"testotag\">$termine_straniero</label><br>";
- $tags .= "<span class=\"checkmark\"></span>";
- } else {
- $tags .= "<input type=\"checkbox\" $checked name=\"tag__and[]\" value=\"{$term->term_id}\">";
- $tags .= "<label class=\"testotag\">{$term->name} </label><br>";
- $tags .= "<span class=\"checkmark\"></span>";
- }
- }
- // Form output
- $output = '<form class="sacconi_form" method="get" action="' . home_url('/') . '">' .
- $categories . $tipologia . $functionOspitiDropdown . $functionCamereDropdown . $functionBagniDropdown . $functionNumberDropdown .
- '<input type="submit" name="search" value="' . esc_html__('Search', 'sacconicase') . '">' . '<br><br>' . $tags . '<input type="submit" name="search" value="' . esc_html__('Search', 'sacconicase') . '">' .
- '</form>';
- return $output;
- }
- //filters
- add_action( 'pre_get_posts', 'bedrooms_guests_search_query');
- function bedrooms_guests_search_query( $query ) {
- if (! is_admin() && $query->is_main_query()) {
- //nuovo test per tag
- if ( array_key_exists('tag__and', $_GET ) && in_array( 203, $_GET['tag__and'])) {
- $query->set('tag__and', array_diff( $_GET['tag__and'], array(203,)));
- $query->set('tag__in', array(203,421,198,441));
- }
- //fine test
- //nuovo test per tag2
- if ( array_key_exists('tag__and', $_GET ) && in_array( 198, $_GET['tag__and'])) {
- $query->set('tag__and', array_diff( $_GET['tag__and'], array(198,)));
- $query->set('tag__in', array(198,441,203,421));
- }
- //fine test
- if ( array_key_exists('function_camere', $_GET ) &&
- array_key_exists('function_ospiti', $_GET ) && array_key_exists('function_bagni', $_GET )&& array_key_exists('function_number', $_GET )) {
- $meta_query = array(
- array(
- 'key' => 'function_ospiti',
- 'value' => (int) $_GET['function_ospiti'],
- 'type' => 'numeric',
- 'compare' => '>=',
- ),
- array(
- 'key' => 'function_camere',
- 'value' => (int) $_GET['function_camere'],
- 'type' => 'numeric',
- 'compare' => '>=',
- ),
- array(
- 'key' => 'function_bagni',
- 'value' => (int) $_GET['function_bagni'],
- 'type' => 'numeric',
- 'compare' => '>=',
- ),
- array(
- 'key' => 'function_number',
- 'value' => $_GET['function_number'] == 0 ? 9999 : $_GET['function_number'],
- 'type' => 'numeric',
- 'compare' => '<=',
- ),
- );
- $query->set("meta_query", $meta_query);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment