Using $post in foreach loop breaks comments on single.php
-
Following on from here:
http://wordpress.org/support/topic/200913?replies=3
It turns out this isn’t resolved, as when i rename $post to $thepost it fixes the comments but breaks the displaying of the_title(), the_permalink() and the_title_attribute();
Here is my code:
<div class="MoreCat"> <?php $categories = get_the_category(); foreach ($categories as $category) : ?> <h3>Similar recent articles</h3> <?php $posts = get_posts('numberposts=5&category='. $category->term_id); foreach($posts as $post) : $values = get_post_meta($post->ID, "Image", true); if (isset($values[0])) { ?> <div class="MoreCatImg"> <img src="<?php bloginfo('template_url'); ?>/scripts/timthumb.php?src=<?php echo $values; ?>&w=102&h=102&zc=1&q=85" alt="<?php the_title(); ?>" /> <div class="MoreCatText"> <a href="<?php the_permalink() ?>" rel="bookmark" title="<?php the_title_attribute(); ?>"><?php the_title(); ?></a> </div> </div> <?php } ?> <?php endforeach; ?> <?php endforeach; ?> </div>
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
The topic ‘Using $post in foreach loop breaks comments on single.php’ is closed to new replies.