WordPress.org

Ready to get started?Download WordPress

Forums

WP_Query() with Tags - possible? (7 posts)

  1. Ryan
    Member
    Posted 6 years ago #

    Hey all, I am working on a rather customized theme and am integrating a "results count" that displays the number of items returned when viewing a category, tag or search page.

    Category and search are all set using:
    new WP_Query("cat=XX");
    or
    new WP_Query("s=XX");
    respectively.

    However, when I use what I assumed would work for tags pages:
    new WP_Query(tag=XX);
    it doesn't return anything.

    Does WP_Query not work the same way for tags as it does for categories and search results?

    Any help is much appreciated.
    DBD

  2. Ryan
    Member
    Posted 6 years ago #

    No one eh? I was afraid of that.

  3. Milo
    Member
    Posted 6 years ago #

    Works, but not with the new_query string,
    just the simple loop and then
    add tag by name instead of cat by ID.

  4. boots
    Member
    Posted 6 years ago #

    Milo says:

    Works, but not with the new_query string,
    just the simple loop and then
    add tag by name instead of cat by ID

    Could you provide a simple loop with tag example please?

    Thanks

    -boots

  5. Evita
    Member
    Posted 6 years ago #

    Have you searched in the codex?

  6. stunnaboi
    Member
    Posted 5 years ago #

    I noticed that tag= won't work but tag_in= works. Running 2.8. Weird.

  7. stunnaboi
    Member
    Posted 5 years ago #

    Wait, I take that back. tag= works fine.

Topic Closed

This topic has been closed to new replies.

About this Topic