I am building a theme that has built into the sidebar a call to display a set of random posts from a given category using the get_posts function. It is configured to display the post title, excerpt, and read more link.
It works perfectly on my main page (index.php). When I am viewing a post or page other than the index page it displays the post title and excerpt properly, but the permalink points to the current active page/post, rather than the post the title and excerpt are pulled from.
This is the code I am using:
<?php
$postslist = get_posts('numberposts=3&orderby=rand&category_name=dog-training-videos');
foreach ($postslist as $post) :
setup_postdata($post); ?>
<div style="border-bottom:1px solid #f0f0f0;">
<br />
<strong><?php the_title(); ?></strong>
<?php the_excerpt(); ?>
<em><a href="<?php the_permalink(); ?>">watch the dog training video...</a></em><br /><br />
</div>
<?php endforeach; ?>
I have a feeling that this has something to do with being on the same page as the loop, but I'm relatively new to template tags still.
This theme is currently active at: http://sitmeanssit.com (the main page displays and functions properly). http://sitmeanssit.com/contact/ is an example of how the permalinks go funny.
Any help or direction on how to tweak this is already appreciated.
Thanks,
Ashton