Opened 17 years ago
Last modified 5 months ago
#5358 assigned defect (bug)
Queried object on multiple tag query holds only first tag
Reported by: | Kafkaesqui | Owned by: | |
---|---|---|---|
Milestone: | Future Release | Priority: | normal |
Severity: | normal | Version: | 2.3.1 |
Component: | Taxonomy | Keywords: | has-patch |
Focuses: | Cc: |
Description
On tag page results when two or more tags are queried (/tags/foo,bar -or- /tags/foo+bar), only the first tag is in the queried object. So a simple:
print_r($wp_query->get_queried_object());
outputs a single associative array of the first tag referenced in the query. One would expect to find an array of all tags in the queried object.
Attachments (3)
Change History (23)
#3
in reply to:
↑ description
@
15 years ago
Replying to Kafkaesqui:
One would expect to find an array of all tags in the queried object.
Semantically, I would expect something named get_queried_object
s()
, not get_queried_object()
, to return an array of all tags queried: the queried object should be just that---the object queried. If we were to change the behavior of get_queried_object()
so that it sometimes returns not an object but an array of objects, we would break all the plugins and themes that expect an object. And we would have to figure out what to do with its complementary method, get_queried_object_id()
.
A better approach might be to create a new method named get_queried_objects()
.
#7
@
12 years ago
- Cc gary@… added
Probably stating the obvious, but this also applies to categories and other taxonomies - not just tags.
#8
@
11 years ago
Maybe best solution is let get_queried_objects() deal with everyhting get_queried_object() currently deals with and modify get_queried_object() to call get_queried_objects() and return the first item in the array. That way we wont have duplicated code.
#9
@
11 years ago
- Keywords has-patch added; needs-patch removed
- Milestone changed from Future Release to 3.7
#10
@
11 years ago
- Keywords needs-refresh added
Patch satisfies the ticket but needs to also support arrays of post_types and authors
#11
@
11 years ago
- Keywords needs-refresh removed
5358.2.diff is a slightly different approach based on @wonderboymusic's work.
#12
@
11 years ago
- Keywords needs-unit-tests added
@kovshenin - looks good, everything needs unit tests
#13
@
11 years ago
- Keywords needs-unit-tests removed
Added some unit tests is 5358.3.diff.
One thing I noticed is that although it works well with multiple tags (and covers the issue described in this ticket), it doesn't really work well with multiple post types for example, because when you specify more than one post type is_post_type_archive
is no longer true. Then again, what should happen when you query a post type with a tag and an author, especially with get_queried_object_ids()
? We might as well just return the whole query_vars
array :-P
#18
@
8 years ago
Could this be moved forward by solving the original reported problem, and then solve multiple post types in a separate ticket?
#19
@
5 years ago
I found this searching in Google: My solution for this in the today version 5.1.1 has been using get_query_var('tag');
#20
@
18 months ago
Looking at this today and many times I had issues for this and needed to create custom URL parameters for filters like for e-commerce (where it can be useful to have multiple categories) it is something that probably today can be very helpful, probably also on REST APIs.
I will try to refresh the patch.
Might this question I posted on wp-hackers a while ago be related?
http://comox.textdrive.com/pipermail/wp-hackers/2007-October/015706.html