Hello, this is my first post here and I hope we'll find a solution to my problem. Here goes.
I've designed a decent template for my blog and had a vision to show random snippets of posts in the sidebar together with blogroll, but the rest (About the author widget, Tag cloud and Categories list) is in the footer.
By reading the codex I've coded a widget in functions.php
function widget_return_sideblog() {
?>
<li id="sideblog" class="widget widget_sideblog">
<h3 class="widgettitle">Sideblog</h3>
<ul>
<?php query_posts('showposts=5&orderby=rand');
while (have_posts()) : the_post(); ?>
<li><h4><a href="<?php the_permalink(); ?>" rel="bookmark" title="<?php the_title(); ?>"><?php the_title(); ?></a></h4><div><?php the_excerpt(); ?></div></li>
<?php endwhile; ?>
</ul>
</li>
<?php }
if ( function_exists('register_sidebar_widget') )
register_sidebar_widget(__('Sideblog'), 'widget_return_sideblog');
?>
Everything works smooth as long as I don't open up a single post; the problem is that with the widget on, comments aren't showed. I figured there's got to be an interference with the loops, but don't know how to solve it. Here's a shortened version of my single.php. As you can see, the sidebar.php comes before the comments.php.
<?php get_header(); ?>
<div id="content">
<?php if (have_posts()) : while (have_posts()) : the_post(); ?>
// Single post stuff //
<?php endwhile; else: ?>
No content.
<?php endif; ?>
</div>
<?php get_sidebar(); ?>
<?php if (have_posts()) : while (have_posts()) : the_post(); ?>
<?php comments_template(); ?>
<?php endwhile; else: ?>
<?php endif; ?>
<?php get_footer(); ?>
So, what am I to do? Thx for your response.