Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Namespace issue in single.php? #130

Open
notthetup opened this issue Jan 12, 2013 · 0 comments
Open

Namespace issue in single.php? #130

notthetup opened this issue Jan 12, 2013 · 0 comments

Comments

@notthetup
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant