WordPress.org

Ready to get started?Download WordPress

Forums

query_posts() problem with multiple tags since 3.1 update (6 posts)

  1. Acualux
    Member
    Posted 3 years ago #

    First of all, hi to everyone and thanks for reading or replying this post.

    I have a problem on a function where I have been using query_posts()
    with multiple tags as parameter, like this:
    myfunction("tag=tag1+tag2").
    Until now it worked quite well, but since the 3.1 update, it has been showing no posts. I want to know if there's a possibility that it could be a bug or an error.

    I thought it would have something to do about the use of taxonomy, but as I see at the Codex:
    http://codex.wordpress.org/Function_Reference/query_posts#Tag_Parameters

    query_posts( 'tag=bread+baking+recipe' );

    It's still fine to use it.

    The thing that makes me more confused is the fact that if I try
    "tag=tag1,tag2" instead of "tag=tag1+tag2", it WORKS! (but I want to force AND "+", not OR ",").

    Thanks again for your time.

  2. Josh Stauffer
    Member
    Posted 3 years ago #

    @Acualux, I just discovered the exact same issue that you are reporting. Please post any solutions you come across and I'll do the same.

  3. Josh Stauffer
    Member
    Posted 3 years ago #

    Alright, I have a solution. I am using WP 3.1.

    Old Query: does NOT work in 3.1

    query_posts( 'cat=8&tag=featured+hotels-and-motels&orderby=rand&posts_per_page=-1' );

    New Query: Works in 3.1!

    $args = array(
    	'cat' => 8,
    	'tag_slug__and' => array( 'featured', 'hotels-and-motels' ),
    	'orderyby' => 'rand',
    	'posts_per_page' => -1,
    );
    query_posts( $args );

    Hope this helps and gets corrected soon.

    -Josh

  4. Acualux
    Member
    Posted 3 years ago #

    Thanks Josh!
    I think I will do something similar but using the renewed taxonomy meanwhile they correct this.

    If I come with another solution or know why this is happening I will post it ASAP.

  5. Josh Stauffer
    Member
    Posted 3 years ago #

    @Acualux, Right on. I did submit a ticket to Trac about the issue.

  6. cbourbeillon
    Member
    Posted 3 years ago #

    I have opened a new thread here, because the former replies here didn't really help me :
    http://wordpress.org/support/topic/url-with-tag1tag2-doesnt-work-since-wp31-update

    I will be grateful to get any suggestion or help to solve my issue. Many thanks !
    :-)

Topic Closed

This topic has been closed to new replies.

About this Topic