WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] Multiple Tag Search? (4 posts)

  1. Leo Blanchette
    Member
    Posted 1 year ago #

    I don't think I'm searching this properly.

    If a post has tags "This" and "that" you will get results if you search for "This" OR "That".

    But if I search "this that" I see that I'm getting no results found. Whats the best way to set up a query for multiple tags?

  2. Leo Blanchette
    Member
    Posted 1 year ago #

    This is a custom post type, so multiple terms is actually more accurate. Not tags. term+term+term returns nothing.

  3. Leo Blanchette
    Member
    Posted 1 year ago #

    I've found similar answers...

    http://wordpress.stackexchange.com/questions/25999/how-to-pass-url-parameters-for-advanced-taxonomy-queries-with-multiple-terms-for/26011#26011

    But it seems my query is returning empty still.

    <?php
    $local_query = array(
        'posts_per_page' => $results_per_page,
        'paged' => $paged,
        'post_type' => 'image',
        'image-tags' => $image_tags,
        'image-type' => $category,
        'tax_query' => array(
            array(
                'taxonomy' => 'image-tags',
                'field' => 'slug',
                'terms' => explode(' ', $image_tags),
                'operator' => 'IN'
            )
        )
    
    );
    
    ?>
  4. Leo Blanchette
    Member
    Posted 1 year ago #

    Solved it. Looks like 'post_type' => 'image', and 'image-tags' => $image_tags, had to be removed.

Topic Closed

This topic has been closed to new replies.

About this Topic