diff --git a/functions.php b/functions.php index b1a25175..82dab70b 100755 --- a/functions.php +++ b/functions.php @@ -495,3 +495,19 @@ function dsi_login_redirect( $redirect_to, $request, $user ) { } add_filter( 'login_redirect', 'dsi_login_redirect', 10, 3 ); + +//riscrivi il meta title nella pagina dei risultati della ricerca +function custom_search_title($title) { + if ( is_search() ) { + // Get the search query + $search_query = get_search_query(); + + if ( empty($search_query) ) { + $title['title'] = esc_html__('Risultati della ricerca', 'design_scuole_italia'); + } else { + $title['title'] = sprintf(esc_html__('Risultati della ricerca per "%s"', 'design_scuole_italia'), $search_query); + } + } + return $title; +} +add_filter('document_title_parts', 'custom_search_title'); diff --git a/search.php b/search.php index 88c080f0..2043fef7 100755 --- a/search.php +++ b/search.php @@ -9,107 +9,215 @@ get_header(); ?> -
- - -
-
-
-
-
-

-

-

- tutto il sito", "design_scuole_italia" ); - } else if ( $_GET["type"] == "school" ) { - $str = __( "nel materiale relativo alla scuola", "design_scuole_italia" ); - } else if ( $_GET["type"] == "news" ) { - $str = __( "in notizie ed eventi", "design_scuole_italia" ); - } else if ( $_GET["type"] == "service" ) { - $str = __( "nei servizi", "design_scuole_italia" ); - } else if ( $_GET["type"] == "education" ) { - $str = __( "nella didattica", "design_scuole_italia" ); - } else if ( $_GET["type"] == "class" ) { - $str = __( "nelle materiale relativo alle classi", "design_scuole_italia" ); - } - }else{ - $str = __( "in base ai filtri selezionati", "design_scuole_italia" ); +

+ + +
+
+
+
+
+

+ found_posts < 1) { + $result = "Nessun risultato"; + } else if ($wp_query->found_posts < 2) { + $result = $wp_query->found_posts . " risultato"; + } else { + $result = $wp_query->found_posts . " risultati"; + } + echo $result . " "; + ?> + +

+ +

+ + "; + } ?> + + label === "Articoli") { + // Special link for "Articoli" + $link = 'tipologia-articolo/articoli/'; + } else { + // Default link + if (isset($post_type->rewrite['slug']) && is_array($post_type->rewrite)) { + $link = esc_url('/' . $post_type->rewrite['slug']); + } else { + // Handle the case where rewrite or slug is not available + $link = esc_url('/'); + } + } + + // Escape the label for output + $post_type_links[] = '' . esc_html($post_type->label) . ''; + } + } + + echo implode(' ', $post_type_links); + } + + + if (isset($_GET["post_types"])) { + // Sanitize input + $post_types = array_map('sanitize_text_field', $_GET["post_types"]); + + $post_type_links = array(); + + foreach ($post_types as $post_type_name) { + $post_type = get_post_type_object($post_type_name); + + if (!empty($post_type)) { + // Check if the label is "Articoli" + if ($post_type->label === "Articoli") { + // Special link for "Articoli" + $link = 'tipologia-articolo/articoli/'; + } else { + // Default link + if (isset($post_type->rewrite['slug']) && is_array($post_type->rewrite)) { + $link = esc_url('/' . $post_type->rewrite['slug']); + } else { + // Handle the case where rewrite or slug is not available + $link = esc_url('/'); + } + } + + // Escape the label for output + $post_type_links[] = '' . esc_html($post_type->label) . ''; + } } - echo " ".$str; - ?> -

-
-
- -
- -
-
-
-
- - - -
-
- + +
+ +
+
+
+
+ + + +
+
+

Filtri

+ + + + + +
+
+
+
+ -
-
-
+ ?> + + + + + false, 'show_title' => true, 'show_browse' => false, - 'labels' => array( - 'search' => esc_html__( 'Risultati Ricerca: %s','design_scuole_italia' ), + 'labels' => array( + 'search' => esc_html__( 'Risultati della ricerca','design_scuole_italia' ), ), 'post_taxonomy' => array( 'servizio' => 'tipologia-servizio', // 'post' post type and 'post_tag' taxonomy diff --git a/template-parts/search/filters-tag.php b/template-parts/search/filters-tag.php index 2e6e57e3..e6f2ea74 100755 --- a/template-parts/search/filters-tag.php +++ b/template-parts/search/filters-tag.php @@ -45,7 +45,7 @@ ?>
  • - onChange="this.form.submit()"> + onChange="this.form.submit()" autocomplete="off">
  • diff --git a/template-parts/search/filters.php b/template-parts/search/filters.php index 1edb0ee7..bc8a6792 100755 --- a/template-parts/search/filters.php +++ b/template-parts/search/filters.php @@ -45,7 +45,7 @@ ?>
  • - onChange="this.form.submit()"> + onChange="this.form.submit()" autocomplete="off">
  • @@ -58,16 +58,23 @@ -

    -