diff --git a/inc/actions.php b/inc/actions.php index ad742dffb..5cfa99d3e 100755 --- a/inc/actions.php +++ b/inc/actions.php @@ -224,7 +224,8 @@ function dsi_eventi_filters( $query ) { */ function dsi_schede_progetti_filters( WP_Query $query ) { - if ( ! is_admin() && $query->is_main_query() && (is_post_type_archive("scheda_progetto") || (get_queried_object()?->taxonomy ?? null) == "tipologia-progetto") ) { + if ( ! is_admin() && $query->is_main_query() && (is_post_type_archive("scheda_progetto") || is_tax("tipologia-progetto")) ) { + //if ( ! is_admin() && $query->is_main_query() && (is_post_type_archive("scheda_progetto") || (get_queried_object()?->taxonomy ?? null) == "tipologia-progetto") ) { $orderby = dsi_get_option("ordinamento_progetti", "didattica") ?? 'date'; $order_direction = dsi_get_option("direzione_ordinamento_progetti", "didattica") === 'asc' ? 'asc' : 'desc'; diff --git a/inc/breadcrumb.php b/inc/breadcrumb.php index 3325f040f..9ffe77766 100755 --- a/inc/breadcrumb.php +++ b/inc/breadcrumb.php @@ -641,7 +641,7 @@ protected function add_term_archive_items() { if ( false !== $taxonomy->rewrite ) { // If 'with_front' is true, dd $wp_rewrite->front to the trail. - if ( $taxonomy->rewrite['with_front'] && $wp_rewrite->front ) + if ( array_key_exists('with_front', $taxonomy->rewrite) && $taxonomy->rewrite['with_front'] && $wp_rewrite->front ) $this->add_rewrite_front_items(); // Get parent pages by path if they exist. @@ -1112,7 +1112,7 @@ protected function get_post_types_by_slug( $slug ) { foreach ( $post_types as $type ) { - if ( $slug === $type->has_archive || ( true === $type->has_archive && $slug === $type->rewrite['slug'] ) ) + if ( $slug === $type->has_archive || ( true === $type->has_archive && is_array($type->rewrite) && isset($type->rewrite['slug']) && $slug === $type->rewrite['slug'])) $return[] = $type; } diff --git a/inc/utils.php b/inc/utils.php index 63a382063..90cd36ef6 100755 --- a/inc/utils.php +++ b/inc/utils.php @@ -1231,4 +1231,27 @@ function dsi_get_progetti_in_luogo($luogo_id) return $progetti; } +} + + + +if(!function_exists("get_page_by_title_new")){ + function get_page_by_title_new( $page_title, $output = OBJECT, $post_type = 'page' ) { + $query = new WP_Query([ + 'post_type' => 'page', + 'title' => $page_title, + 'post_status' => 'publish', // Opzionale: solo pagine pubblicate + 'posts_per_page' => 1, // Opzionale: limitare a un risultato + ]); + + $page = null; + + if ($query->have_posts()) { + $query->the_post(); + $page = get_post(); // Recupera l'oggetto del post corrente + wp_reset_postdata(); // Resetta i dati del loop di WordPress + } + + return $page; + } } \ No newline at end of file