• 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

Viewing 3 replies - 1 through 3 (of 3 total)
  • Thread Starter willm73

    (@willm73)

    Oh, one more thing: my site is http://www.sketchmates.com/blog

    Thx,
    Will

    Thread Starter willm73

    (@willm73)

    Oops2: Looks like I need to repost the code:

    <li class=”widget”><h2 class=”widgettitle”>Posts</h2>
    <?php query_posts(‘category_name=Posts’); ?>

    Thread Starter willm73

    (@willm73)

    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

Viewing 3 replies - 1 through 3 (of 3 total)

The topic ‘Blogroll disappears after using query_posts’ is closed to new replies.