italia / design-wordpress-theme-italiaWP2

Tema WordPress open-source per la Pubblica Amministrazione basato su Bootstrap Italia
Other
32 stars 19 forks source link

News in evidenza homepage conteggio errato #35

Closed digi-vision closed 1 year ago

digi-vision commented 2 years ago

Anche se ci sono 2 news in evidenza, mostra le 2 news e nuovamente le stesse 2 news. Analizzando il codice ed estendendo il codice su un tema child, abbiamo risolto cosi:

<?php /*

0) { // Primo loop con sticky posts $args = array( 'posts_per_page' => $sticky, 'post__in' => get_option('sticky_posts'), ); $do_not_duplicate = array(); $query = new WP_Query($args); while ($query->have_posts()) : $query->the_post(); $x++; $do_not_duplicate[] = $post->ID; $img_url = wp_get_attachment_image_src(get_post_thumbnail_id($post->ID), 'news-image'); if ($img_url != "") { $img_url = $img_url[0]; } else if (get_theme_mod('active_immagine_evidenza_default')) { $img_url = esc_url(get_theme_mod('immagine_evidenza_default')); if ($img_url == "") { $img_url = esc_url(get_template_directory_uri()) . "/images/400x220.png"; } } $category = get_the_category(); $posttags = get_the_tags(); $datapost = get_the_date('j F Y', '', ''); ?>
ID)) { ?>
">

term_id)) . '" title="' . esc_html($cat->name) . '" class="badge badge-pill badge-argomenti">' . esc_html($cat->name) . ''; } ?>

name) . '" class="badge badge-pill badge-argomenti">' . esc_html($tag->name) . ''; } ?>
$allstickys, 'post__not_in' => $do_not_duplicate ); } } else { $args = array( 'posts_per_page' => $num_articoli, 'post__not_in' => get_option('sticky_posts') ); } $the_query = new WP_Query($args); if ($the_query->have_posts()) : while ($the_query->have_posts()) : $the_query->the_post(); $img_url = wp_get_attachment_image_src(get_post_thumbnail_id($post->ID), 'news-image'); if ($img_url != "") { $img_url = $img_url[0]; } else if (get_theme_mod('active_immagine_evidenza_default')) { $img_url = esc_url(get_theme_mod('immagine_evidenza_default')); if ($img_url == "") { $img_url = esc_url(get_template_directory_uri()) . "/images/400x220.png"; } } $category = get_the_category(); $posttags = get_the_tags(); $datapost = get_the_date('j F Y', '', ''); ?>
term_id)) . '" title="' . esc_html($cat->name) . '" class="badge badge-pill badge-argomenti">' . esc_html($cat->name) . ''; $i++; } } } ?>
">

name) . '" class="badge badge-pill badge-argomenti">' . esc_html($tag->name) . ''; } ?>
digi-vision commented 2 years ago

La pagina in questione è: section-last-news.php

borisamico commented 1 year ago

Problema risolto con le ultime versioni del tema.