themeskult / wp-svbtle

Wordpress Admin & Theme inspired by Svbtle
http://wp-svbtle.com
1.45k stars 220 forks source link

Namespace issue in single.php? #130

Open notthetup opened 11 years ago

notthetup commented 11 years ago

I noticed the code used to show the "Also read" links uses the variable names $posts and $post.

<?php
$posts=$wpdb->get_results($wpdb->prepare(
 "SELECT post_id, meta_value FROM $wpdb->postmeta WHERE meta_key = %s " .
 "ORDER BY CHAR_LENGTH(meta_value) DESC, meta_value DESC LIMIT 5",
 '_wp-svbtle-kudos'
));
?>
  <?php foreach ( $posts as $post ) {?>
    <li>
      <a href="<?php echo get_permalink($post->post_id); ?>">
        <h3><?php echo get_the_title($post->post_id); ?></h3>
        <p class="link_kudo"><?php echo $post->meta_value; ?></p>
      </a>
    </li>
  <?php }; ?>

I believe somehow the call to comments_template() has $posts set as posts from query ($wpdb->get_results) and hence the comments don't show up properly.

For me I was seeing my single posts displaying comments from various other posts. Changing the names of the variables helped to fix the issue. I have the code on this branch

https://github.com/notthetup/wp-svbtle/tree/single_namspace_fix