WordPress.org

Forums

Query string for multiple categories (1 post)

  1. Sivar
    Member
    Posted 8 years ago #

    Hi,

    I'd like to put a link on my page, which requests the latest say 20 posts from multiple categories (in fact, from all categories but cat1), so that The Loop gets that query.
    The thing is, I don't want to use query_posts() because most of the time there are just posts from one category displayed by The Loop using "default" URLs like [...]/category/mycategory/ and naturally I don't want both.

    What variables does the URL need, and what values? I know, that there is "cat=x", but this only seems to work for one category, and excluding ("cat=-x") doesn't work either.

    It seems, a second query and if-condition just before The Loop could solve my problem, like:
    if (!is(category()) { $myquery = query_posts(); while ($myquery->have_posts()) : $myquery->the_post(); ... endwhile; } else { The usual Loop }
    But there has to be a more elegant way to do it...?

    Any assistance would be very much appreciated, since I'm trying to figure that out for hours now *g*. Thanks in advance...

    Sivar

Topic Closed

This topic has been closed to new replies.

About this Topic