Forums

[resolved] Category Posts Filters & Tag Filters via dropdown menu (7 posts)

  1. jcprovideo
    Member
    Posted 3 years ago #

    I have the need to preform post filtering over various posts and tags.
    I made visual example to help demonstrate what I'm trying to do

    1) Basically I've got a page that I only display posts from specific categories.
    <?php query_posts("cat=7,4,8"); ?>
    I would like to have the posts display under their respective categories (I.E. under their titles...see screen). I can do this manually by making a query posts for each category, but this is not that efficient as it requires more code and manual effort each time I add a new category to the list. Is there a more efficient way of querying posts and having the result separate the posts based on category? If not I will go with the other.

    2) I would like to add filtering to the mix as well. I would like to have the user be able to select/filter (via link or dropdown) by category and by tag. So, if the user selects cat-1 all posts from cat-1 are displayed. So then if they select tag-1 all posts are shown from cat-1 and tag-1. Seems to me this would need to be accomplished by creating a lot of pages with the desired results already populated on them. However, if there is a way to do this using the same page template, using if statements, and some clever PHP I am all for it.

    Thanks in advance

  2. jcprovideo
    Member
    Posted 3 years ago #

    Any idea's on either one of the questions?

  3. jcprovideo
    Member
    Posted 3 years ago #

    Has anybody accomplished this kind of sorting in wordpress. Is there another method I should be looking at? Any help would be awesome :)

  4. jcprovideo
    Member
    Posted 3 years ago #

    So here is a much more simple question: can you query posts by category and tags? So far I have only been able to query by category or tags...not both.

  5. Evita
    Member
    Posted 3 years ago #

    From the codex:

    query_posts('cat=1&tag=apples');
    query_posts('cat=1&tag=apples+apples');

  6. jcprovideo
    Member
    Posted 3 years ago #

    u serious...its that easy... Man I suck. Thanks for your help!

  7. connectr
    Member
    Posted 3 years ago #

    Howdy folks :)
    I am trying to do the same as Jason, but in a way that is automated. IE, if a user selects category x they can refine the results by filtering the relevant tags that have been used for those posts.

    You guys know if anything like this exists? I've searched the forums/web and this is all i was able to come up with.

    Any suggestions would be much appreciated!

    Thanks,
    Chris

Topic Closed

This topic has been closed to new replies.

About this Topic