WordPress.org

Make WordPress Core

Opened 9 years ago

Closed 9 years ago

#15363 closed defect (bug) (fixed)

When 'taxonomy' and 'term' are queried, other tax-type query args are ignored.

Reported by: filosofo Owned by: scribu
Milestone: 3.1 Priority: normal
Severity: normal Version: 3.1
Component: Query Keywords: has-patch
Focuses: Cc:

Description

Steps to Reproduce

The following is the content of a simple page template. Assign it to a page and view that page.

page template content:

<?php

/*
Template Name: Test Template
*/

// note that below you will need to replace "a tag" and "a category name" with actual tag and category properties.
$query_args = array(
        'taxonomy' => 'post_tag',
        'term' => 'a tag',
        'category_name' => 'a category name',
);

echo 'query args:';
var_dump( $query_args );

query_posts( $query_args );

echo '<ul>';
while (have_posts() ) : 
        the_post();
        echo '<li>';
                the_title();
                echo 'tags: ' . get_the_tag_list( '', ', ' );
                echo 'categories: ' . get_the_category_list( '', ', ' );
        echo '</li>';
endwhile;
echo '</ul>';

Problem

In WordPress 3.0, the result prints the posts that are assigned both the tag and the category.

In trunk, the result prints the posts that are assigned the tag; the category name query parameter is ignored.

Solution

Patch allows both the use of a mixture of taxonomy query arguments.

It's not clear from the diff, but it's basically just moving the foreach wp_taxonomies loop out of the scope of the else statement.

Attachments (1)

dont-ignore-tax-parameters.15363.diff (1.8 KB) - added by filosofo 9 years ago.

Download all attachments as: .zip

Change History (5)

#1 @filosofo
9 years ago

Yeah, that diff renders horribly. The patch is not changing the preg_split line, as it initially appears.

#2 @scribu
9 years ago

  • Owner set to scribu
  • Status changed from new to accepted

#3 @scribu
9 years ago

Confirmed.

#4 @scribu
9 years ago

  • Resolution set to fixed
  • Status changed from accepted to closed

(In [16259]) Allow mix of 'taxonomy' => 'foo', 'term' => 'bar' and 'foo2' => 'bar2'. Props filosofo. Fixes #15363

Note: See TracTickets for help on using tickets.