WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] query posts multiple queries (9 posts)

  1. Mark Steggles
    Member
    Posted 5 years ago #

    How do I modify this line to also exclude a category?

    <?php query_posts($query_string.'&orderby=title&order=ASC'); while (have_posts()) : the_post(); ?>

  2. tugbucket
    Member
    Posted 5 years ago #

    http://codex.wordpress.org/Template_Tags/query_posts

    to exclude a category you write cat=-3 notice the '-' before the category ID.

  3. Mark Steggles
    Member
    Posted 5 years ago #

    Im having trouble working that into the same line:

    query_posts($query_string.'&orderby=title&order=ASC', 'cat=-Archive');

    is that correct?

  4. tugbucket
    Member
    Posted 5 years ago #

    try using the category ID instead of the name and try this line:

    query_posts('orderby=title&order=ASC&cat=-ID#');

    where ID# is the ID of 'Archive'. You can look in the admin panel under manage -> categories and find the ID# there.

  5. Mark Steggles
    Member
    Posted 5 years ago #

    Im using wp 2.7 and I cant see id numbers for the categories

  6. Mark Steggles
    Member
    Posted 5 years ago #

    category_name=- doesnt seem to work

    query_posts($query_string.'orderby=title&order=ASC&category_name=-Archive')

  7. mores
    Member
    Posted 5 years ago #

    When in the dashboard, edit the categories. When you move your mouse over the existing categories, you'll see the ID in the URL that is displayed in most browsers' status area, usually lower left.

  8. Mark Steggles
    Member
    Posted 5 years ago #

    Ah I see the id number now. Still not got a solution. All I want to do is exclude a category from my home page (index.php)

    <?php if (have_posts()) : ?>

    <?php query_posts($query_string.'orderby=title&order=ASC'); while (have_posts()) : the_post(); ?>

  9. Mark Steggles
    Member
    Posted 5 years ago #

    I used a plugin instead

    Thanks

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.