WordPress.org

Ready to get started?Download WordPress

Forums

Multiple category searches via query string? (5 posts)

  1. fumbly
    Member
    Posted 8 years ago #

    I'd like to be able to pull up a set of post that belong to multiple categories/subcategories.

    So if you have:

    Cat 1
    Cat 1.1
    Cat 1.2
    Cat 2
    Cat 2.1

    You could display posts that belonged to Cat 1.1 and Cat 2.1, ideally through manipulating the query string (so static pages can be used as customised advanced search options).

    Does anyone know how to do this or if there's a workaround/hack/plugin that provides this functionality (without using tags)? Any suggestions greatly appreciated!

  2. Kafkaesqui

    Posted 8 years ago #

    You can perform a multiple category search by appending the 'cat' query key, with the category ID for each category as the value (separating each with a comma):

    /?s=search+term&cat=1,2,3

  3. fumbly
    Member
    Posted 8 years ago #

    Fantastic! Thank you - been looking for that answer for a while, but I'd kept trying "&" and "+" amongst other things.

  4. Dgold
    Member
    Posted 8 years ago #

    Nice one, thanks for showing that.

    Not the topic of this thread, but related, I am still looking for a way to search based on custom fields.

  5. Kafkaesqui

    Posted 8 years ago #

    Dgold, right now the only way I know to do that is with a hack of the source:

    http://randomfrequency.net/wordpress/search-meta/

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.