I'm using Wordpress and have been putting bits of PHP together to produce the following:
This then displays the "Similar recent articles" section found on this page:
http://richl.com/2008/09/10/apple-release-iphone-21-this-friday/
It has five images and works a treat....on MOST of my pages! And this is the problem, here's an example:
http://richl.com/2007/10/08/sick-of-uk-house-prices/ and another:
http://richl.com/2007/04/28/second-quarterly-update-april-2007/
etc...etc...
I'd say around 80% of my pages are fine, but the rest display this additional image and im not sure why. So far i have echoed $currentpage and $post->ID and on every page they display the correct post ID twice (e.g. 6 and 6, 42 and 42, etc)...
Can anyone help?!
Code:
<h2>Similar recent articles</h2>
<div class="morecat">
<?php
$categories = get_the_category();
foreach ($categories as $category) :
?>
<?php
$thepost = $post;
$currentpage = $post->ID;
if ($post->ID == $currentpage) {
$posts = get_posts('numberposts=6&category='. $category->term_id);
} else {
$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])) {
if ($post->ID !== $currentpage) { ?>
<div class="morecatimg">
<img src="<?php bloginfo('template_url'); ?>/scripts/timthumb.php?src=<?php echo $values; ?>&w=105&h=105&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;
$post = $thepost; ?>
</div>
This then displays the "Similar recent articles" section found on this page:
http://richl.com/2008/09/10/apple-release-iphone-21-this-friday/
It has five images and works a treat....on MOST of my pages! And this is the problem, here's an example:
http://richl.com/2007/10/08/sick-of-uk-house-prices/ and another:
http://richl.com/2007/04/28/second-quarterly-update-april-2007/
etc...etc...
I'd say around 80% of my pages are fine, but the rest display this additional image and im not sure why. So far i have echoed $currentpage and $post->ID and on every page they display the correct post ID twice (e.g. 6 and 6, 42 and 42, etc)...
Can anyone help?!
Last edited: