Hi all, I use Mimbo Pro, and I am customizing it.
I want to be able to do the following as a widget in the sidebar.
1. From a selected category ID
2. Choose a random post
3. Display a small image from that post linked to that post
4. Display title of the post linked to that post
I actually got this working perfectly on my homepage (index.php). However, when I use the same code in the sidebar, the following happens: I get the sidebar image/text/link that I want, but every page or post in my site only displays the content from the random post that is in the sidebar. That means that, if I am on the "About Us" page, it is still showing the content of the random post from the sidebar.
How can I do what I want without messing up my blog?
I know that there is a Category Posts widget plugin, but that won't show a random entry from a category. Also, I want to have custom styles for this sidebar item.
<?php
// --------------------
// list of students seeking sponsors
// --------------------
query_posts('showposts=1&cat=33&orderby=rand');
if(have_posts()) {
while (have_posts()) {
the_post();
$image = get_post_image(50, 50);
?>
<div id="sss-widget">
<div id="sss-widget-title"><a href="index.php?page_id=305">Sponsor a Student</a></div>
<div id="sss-widget-text">
<?php
if($image != "") {
?>
<a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php echo $image; ?></a>
<h4><a href="<?php the_permalink() ?>" rel="bookmark" title="<?php the_title_attribute(); ?>" alt="<?php the_title_attribute(); ?>"><?php the_title(); ?></a></h4>
<a href="index.php?page_id=305">View other students seeking sponsors</a>
</div>
</div>
<?php
} } }
?>