[Résolu] Erreur Undefined property : stdClass::$ID (Créer un compte)

  • WordPress :5.2
  • Statut : résolu
2 sujets de 1 à 2 (sur un total de 2)
  • Auteur
    Messages
  • #2300466
    Cecilia37
    Participant
    Padawan WordPress
    51 contributions

    Bonjour,

    Ma configuration WP actuelle :

    • – Version de WordPress : 5.3.2
    • – Version de PHP/MySQL : 7.2.19 / 5.6.43
    • – Thème utilisé : Hestia Pro
    • – Thème URI : https://themeisle.com/themes/hestia-pro/
    • – Extensions en place : Additional Variation Images Gallery for WooCommerce (1.1.37), All In One SEO Pack (3.3.5), API KEY for Google Maps (1.2.0), ARVE Advanced Responsive Video Embedder (8.10.20), Autoptimize (2.6.2), Autoptimize CriticalCSS.com Power-Up (1.18.0), Caldera Forms (1.8.10), Caldera Forms Anti Spam (0.2), Cookie Notice (1.2.50), Download Monitor (4.4.2), Elementor (2.9.3), Email Encoder – Protect Email Addresses (2.0.6), Email Templates (1.3.1.2), Enable Media Replace (3.3.10), Final Tiles Grid Gallery – Image Gallery (3.4.18), Folders (2.4.2), Forum_wordpress_fr (4.2), Gutenberg Blocks and Template Library by Otter (1.4.0), Ivory Search (4.4.6), MaxButtons (7.13.4), Orbit Fox Companion (2.9.2), Redirection (4.7), Sendinblue Subscribe Form And WP SMTP (2.9.11), Shortcodes Ultimate (5.7.0), Title and Nofollow For Links (1.09), Variation Swatches for WooCommerce (1.0.76), WooCommerce (3.9.2), WP-Advanced-Search (3.3.3), YITH WooCommerce Catalog Mode (1.6.16)
    • – Adresse du site : https://weser.fr
    • – Nom de l’hébergeur : Apache

     

    Problème(s) rencontré(s) :

    Sur ma page https://weser.fr/distributeurs-weser/ quand je valide le formulaire et qu’il me trouve des distributeurs, le message ci-dessous s’affiche après les résultats. Sauriez-vous pourquoi?

    <b>Notice</b>: Undefined property: stdClass::$ID in <b>[…]/themes/hestia-pro/inc/views/pluggable/class-hestia-metabox-view.php</b> on line <b>80</b>

    Mon code est le suivant :

    <div id= »form_rech_distrib »>

    <form action= »#recherche » method= »post »>
    <table class= »tab_rech_distrib »>
    <tr><td colspan= »2″ align= »center »><h3>Rechercher un distributeur :</h3></td></tr>
    <tr>
    <td style= »text-align:right; » width= »50% »>Département (nombre à 2 chiffres) :</td>
    <td width= »50% »><input class= »departement » type= »text » name= »cp » value= » » /></td>
    <tr><td colspan= »2″ align= »center »><input name= »Rechercher » type= »submit » value= »Rechercher »></td>
    </tr>
    </table>

    </form>
    </div>
    <div id= »resultat_rech_distrib »>
    <?php
    // 1st Method – Declaring $wpdb as global and using it to execute an SQL query statement that returns a PHP object

    //isset détermine si la variable est nulle

    if (isset($_POST[« cp »])>0)
    {
    $rech=$_POST[« cp »];
    echo « <h3>Liste des distributeurs pour le département (tri par ville) : « .$rech. »</h3><br> »;

    global $wpdb;

    // séléction des clients dont le code postal contient la recherche

    $rech_sql= »select * from ex_client where cp Like ‘$rech%’ and secteur not like ‘%export%’ and secteur not like ‘%Ciabattoni%’ and secteur not like ‘%Enseigne%’ and secteur not like ‘%Poncheville%’ order by ville »;

    $resultats = $wpdb->get_results($rech_sql);

    if ($resultats!=FALSE)
    {
    ?>
    <table><?php
    // Parcours des resultats obtenus
    foreach ($resultats as $post) {
    echo « <tr><td style= »background-color:#e91e63 !important;color:#ffffff;font-weight:bold » colspan= »2″> ».$post->societe. »</td></tr><tr><td colspan= »2″> ».$post->adresse1. » « .$post->adresse2. » « .$post->adresse3. » « .$post->cp. » <span style=’color:#01a5ca’> ».$post->ville. »</span></td></tr><tr><td> Tel : « .$post->tel. »</td><td>societe. »+ ».$post->adresse1. »+ ».$post->cp. »+ ».$post->ville. » » target= »_blank » title= »Localiser ce distributeur Weser »>Localiser</td></tr> »;
    }
    ?>
    </table>

    <?php
    }
    else
    {
    echo « <h4 style= »color:#01a5ca; »>Désolé, aucun distributeur n’a été trouvé dans ce département.</h4> »;
    }

    }
    ?></div>

     

     

    • Ce sujet a été modifié le il y a 4 années et 11 mois par Cecilia37.
    • Ce sujet a été modifié le il y a 4 années et 11 mois par Cecilia37.
    • Ce sujet a été modifié le il y a 4 années et 11 mois par Cecilia37.
    #2300476
    Cecilia37
    Participant
    Padawan WordPress
    51 contributions

    Problème résolu,

    Dans ma page : […]/themes/hestia-pro/inc/views/pluggable/class-hestia-metabox-view.php

    J’ai modifier le code

    return $post->ID;

    par :

    if (isset($post->ID))
    {
    return $post->ID;
    }
    else
    {
    return null;
    }

2 sujets de 1 à 2 (sur un total de 2)
  • Vous devez être connecté pour répondre à ce sujet.