Hi,
I've been modding my Wordpress theme template (mostly single.php) to show "Other articles from this category", but instead of just text i have made it so it also shows the custom field from the post which is an image.
An example can be seen on my site here, if you look down the page you'll see a list of other recent articles in the same category, note that i'm NOT talking about the "More from this category" section on the right...that bits fine!
http://richl.com/2008/05/20/know-your-limit/
The PHP i used is below, i'm not particularly PHP awesome (
) so have just been hacking bits together basically, the code i have works but any comments i view for one post will appear on another in the same category! For example, say i have Post A and Post B in Category 1, if i comment on Post A in Category 1 it will also display for Post B...but it wouldn't display in Category 2. I believe it's to do with using $post, as when i rename it to $thepost or similar the comments work, but it then breaks what i want it to do as it will no longer retrieve the_title() or the_permalink() etc.
Here's the code, when i remove this it works fine so it must be the following bit of code:
Can anyone help?
I've been modding my Wordpress theme template (mostly single.php) to show "Other articles from this category", but instead of just text i have made it so it also shows the custom field from the post which is an image.
An example can be seen on my site here, if you look down the page you'll see a list of other recent articles in the same category, note that i'm NOT talking about the "More from this category" section on the right...that bits fine!
http://richl.com/2008/05/20/know-your-limit/
The PHP i used is below, i'm not particularly PHP awesome (

Here's the code, when i remove this it works fine so it must be the following bit of code:
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>
Can anyone help?