Blogroll disappears after using query_posts
-
Hi,
I want to customize my sidebar to show posts under headings I’ve added to sidebar.php, based on the category assigned to each post. When I use get_posts, it lists posts under the h2 headings I’ve added, but it doesn’t distinguish between categories– it just lists all posts. I have better luck with listing posts by category using query_posts, but for some reason when query_posts is added, the blogroll disappears from the sidebar. Here is the code:<li class=”widget”><h2 class=”widgettitle”>Posts</h2>
<?php query_posts(‘category_name=Posts’); ?>-
<?php while (have_posts()) : the_post(); ?>
- ”><?php the_title(); ?>
If I add this code to the end of sidebar.php, just before the closing div tag, the blogroll doesn’t get wiped out. But I want to position this heading at the top of the sidebar.
Where does this code go wrong?
Thanks!
Will
-
Oh, one more thing: my site is http://www.sketchmates.com/blog
Thx,
WillOops2: Looks like I need to repost the code:
<li class=”widget”><h2 class=”widgettitle”>Posts</h2>
<?php query_posts(‘category_name=Posts’); ?>-
<?php while (have_posts()) : the_post(); ?>
- ”><?php the_title(); ?>
<?php endwhile;?>
I may have solved the problem. That is, I found some code that Otto42 posted for someone who had lost the sidebar blogroll for a different reason. With this code posted in sidebar.php, the blogroll now appears:
<ul><li class="listHeader"><h2><?php _e('Archives'); ?></h2> <?php wp_get_archives('type=monthly'); ?> </ul> <ul><?php wp_list_bookmarks('before=<li>&after=</li>&orderby=name&show_description=0&show_updated=1'); ?> </ul>Problem “solved”, although I haven’t learned by using query_post(category_name=) in sidebar.php was causing the blogroll to disappear.
Will
The topic ‘Blogroll disappears after using query_posts’ is closed to new replies.