WordPress.org

Ready to get started?Download WordPress

Forums

Second Query Breaks Nav Links (3 posts)

  1. melbell
    Member
    Posted 8 years ago #

    I have the following that I am using to show the post titles of one category in my sidebar:


    <?php $my_query = new WP_Query('category_name=Plugins&showposts=10'); ?>
    <?php while ($my_query->have_posts()) : $my_query->the_post(); ?>
    <li><h2>Testing</h2>
    <ul>
    <li><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title(); ?>"><?php the_title(); ?></a></li>
    </ul>
    <?php endwhile; ?>

    It works fine, in itself, but it causes my Previous and Next links on my archive pages to disappear. How can I fix this?

  2. Firas
    Member
    Posted 8 years ago #

    If you just want titles/links, try http://codex.wordpress.org/Template_Tags/get_posts

  3. melbell
    Member
    Posted 8 years ago #

    Ok, here's what I did:


    <?php
    $posts = get_posts('numberposts=20&category=8');
    foreach ($posts as $post) : ?>
    <li><h2>Testing</h2>
    <ul>
    <li><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title(); ?>"><?php the_title(); ?></a></li>
    </ul>
    <?php endforeach; ?>

    It seems to be working fine! Thanks! :)

Topic Closed

This topic has been closed to new replies.

About this Topic