Quelqu’un a une idée? (Créer un compte)

  • Statut : non résolu
2 sujets de 1 à 2 (sur un total de 2)
  • Auteur
    Messages
  • #512082
    studio5150
    Participant
    Chevalier WordPress
    277 contributions

    Bonjour,
    je cherche à afficher sur ma home page les deux dernier commentaire avec le résultat d’un rating d’une autre table… Lorsque je lance la requête dans PhpMyAdmin j’ai le bon résultat… Mais dans ma home page le résultat reste VIDE…

    <?php
    global $wpdb;

    $sql = "SELECT *
    FROM $wpdb->bxlC_comments JOIN $wpdb->bxlC_commentmeta ON ($wpdb->bxlC_comments.comment_ID = $wpdb->bxlC_commentmeta.comment_id)
    WHERE $wpdb->bxlC_comments.comment_approved = ‘1’
    ORDER BY $wpdb->bxlC_comments.comment_date_gmt DESC
    LIMIT 2″;

    $comments = $wpdb->get_results($sql);

    $output = « n<ul>« ;
    foreach ($comments as $comment) {
    $output .= « n<li>« .strip_tags($comment->comment_author)
    . »: » . « <a href="" . get_permalink($comment->ID) .
    « #comment- » . $comment->comment_ID . «  » title= »on  » .
    $comment->post_title . «  »> » . strip_tags($comment->com_excerpt)
    . »</a></li>« ;
    }
    $output .= « n</ul>« ;
    echo $output; ?>

    Merci

    #842881
    luciole135
    Participant
    Maître WordPress
    13714 contributions

    Sans être certain du résulat, essayez cette requête :

    $sql = « SELECT * 
    FROM $wpdb->comments as T1 JOIN (SELECT comment_id FROM $wpdb->commentmeta as T2) ON T1.comment_ID = T2.comment_id
    WHERE T1.comment_approved = ‘1’
    ORDER BY T1.comment_date_gmt DESC
    LIMIT 2 »;

2 sujets de 1 à 2 (sur un total de 2)
  • Le forum ‘Utilisation spécifique de WordPress’ est fermé à de nouveaux sujets et réponses.