Dall’uso in una mia scuola più utenti hanno ricontrato problemi nella pagina delle “Carte della Scuola” che senza motivo ha assunto il layout da smartphone andando in poi in errore.
Con il mio staff abbiamo analizzato il codice del file da dove proviene l’errore che ho rilevato attivando il debug:
[09-May-2026 05:34:58 UTC] PHP Warning: Attempt to read property “slug” on false in /web/htdocs/www.sitoscuola.edu.it/home/wp-content/themes/design-scuole-wordpress-theme-main/archive-documento.php on line 29
[09-May-2026 05:34:58 UTC] PHP Warning: Attempt to read property “name” on false in /web/htdocs/www.sitoscuola.edu.it/home/wp-content/themes/design-scuole-wordpress-theme-main/archive-documento.php on line 44
[09-May-2026 05:34:58 UTC] PHP Fatal error: Uncaught Error: Object of class WP_Error could not be converted to string in /web/htdocs/www.sitoscuola.edu.it/home/wp-content/themes/design-scuole-wordpress-theme-main/archive-documento.php:55
Abbiamo patchato il file: archive-documento.php in questo modo (riporto solo il codice estratto dalla riga 22 alla 67):
if($strutture_documenti) {
foreach ($strutture_documenti as $id_tipologia_documento) {
$tipologia_documento = get_term_by("id", $id_tipologia_documento, "tipologia-documento");
if (!is_wp_error($tipologia_documento)) {
**if ($tipologia_documento->slug) { // Corregge bug Attempt to read property "slug" on false by MS 09/05/2026**
$documenti = get_posts("post_type=documento&tipologia-documento=" . $tipologia_documento->slug . "&posts_per_page=6");
if (is_array($documenti) && count($documenti) > 0) {
$i++;
$classcolor = "bg-white";
if ($i % 2)
$classcolor = "bg-gray-light";
?>
<section class="section <?php echo $classcolor; ?> py-5">
<div class="container">
<?php
if (is_array($documenti) && count($documenti) > 0) {
?>
<div class="title-section mb-5">
<h2 class="h4">
<?php if (is_array($documenti) && count($documenti) > 1) echo dsi_pluralize_string($tipologia_documento->name); else echo $tipologia_documento->name; ?>
</h2>
</div><!-- /title-section -->
<div class="row variable-gutters">
<?php foreach ($documenti as $documento) { ?>
<div class="col-lg-4 mb-3 mb-lg-4">
<?php get_template_part("template-parts/documento/card", "ico"); ?>
</div><!-- /col-lg-4 -->
<?php } ?>
</div><!-- /row -->
<div class="pt3 text-center">
<a class="text-underline" href="<?php echo get_term_link($tipologia_documento) ?>"><strong><?php \_e("Vedi tutti", "design_scuole_italia"); ?></strong></a>
</div>
<?php
}
?>
</div><!-- /container -->
</section><!-- /section -->
<?php
}
**} // end Corregge bug Attempt to read property "slug" on false**
}
}
}
Il problema si è risolto, versione tema: 2.18.0