Make WordPress Core

Opened 13 years ago

Closed 10 years ago

#12719 closed enhancement (worksforme)

Custom taxonomy with query_var set, gets taxonomy query_var appended anyway

Reported by: silkjaer's profile Silkjaer Owned by: dd32's profile dd32
Milestone: Priority: normal
Severity: normal Version: 3.0
Component: Query Keywords:
Focuses: Cc:

Description

In my browser address field, appending my WP url with "?customtax=termslug", the real WP query string gets changed to "?customtax=termslug&taxonomy=customtax&term=termslug".

This causes cases where I append two custom taxes in the URL to not work. E.g. "?customtax1=termslug1&customtax2=termslug2" would result in something like "?customtax1=termslug1&taxonomy=customtax1&term=termslug1&customtax2=termslug2" and not work.

If i two sets of custom taxonomies and slugs manually through a query_posts it works, and is not modified by WP.

Change History (9)

#1 @dd32
13 years ago

  • Milestone changed from Unassigned to 3.0
  • Owner changed from ryan to dd32
  • Status changed from new to accepted

#2 @dd32
13 years ago

  • Component changed from Query to Canonical

#3 @dd32
13 years ago

  • Component changed from Canonical to Query
  • Keywords reporter-feedback added; taxonomy query_vars removed

Can you just verify the bug you're seeing?

Is WordPress -redirecting- you to the other URL you're mentioning? Or is this related to the Query Vars which are presented to WordPress?

Given the URL: http://localhost/wordpress/?state=nsw&colour=red I'm seeing NSW Posts which are also Red.

While WordPress is loading the page correctly, The Query vars do get messed up, For example:

array
  'state' => string 'nsw' (length=3)
  'taxonomy' => string 'colour' (length=6)
  'term' => string 'red' (length=3)
  'colour' => string 'red' (length=3)

The last added one is taking preference over the earlier ones.

From the description I thought this was a canonical redirection, but i cant seem to see that, I'm setting back to Query pending duplication.

Can you post up the register_taxonomy() calls which you're using to cause this? It might be dependent on a option you've got set.

#4 @Silkjaer
13 years ago

It happens as you describe it - no redirection, just a change of the internal query vars. But only if i add "tax=term" in the URL and not in a query_posts in the theme/plugin.

I made a quick fix by unsetting $wp_query->querytaxonomy? and $wp_query->queryterm?, then running query_posts again.

My register_taxonomy()'s:

register_taxonomy(
		'genre',
		array(
			'udgivelser',
			'koncerter',
			'kunstnere'
		),
			array(
				'hierarchical' => false,
				'label' => __('Tag: Genre'),
				'query_var' => 'genre',
				'rewrite' => false
		)
	);
	
	register_taxonomy(
		'land',
		'kunstnere',
			array(
				'hierarchical' => false,
				'label' => __('Tag: Land'),
				'query_var' => 'land',
				'rewrite' => false
		)
	);

#5 @dd32
13 years ago

  • Keywords needs-patch added; reporter-feedback removed
  • Milestone changed from 3.0 to 3.1
  • Type changed from defect (bug) to enhancement

Ah, I see what i've done wrong. I only had one post with a colour attached.. The last taxonomy option provided wins over all others.

Sorry, You're right, Custom taxonomies dont support Intersections.

You can have an intersections between

  • (multiple) Categories, (multiple) Tags
  • (multiple) Categories, (multiple) Tags, and a Custom Taxonomy

But you cannot have

  • Custom Taxonomy 1, Custom Taxonomy 2

I'm setting this to 3.1 as from what i can see, Its not supported yet, and as such, is an enhancement. There is another ticket around to add something similar (I think it was taxonomyin/taxonomynot_in and friends) but i cant find it right now.

#6 @nacin
13 years ago

There is another ticket around to add something similar

#9951

#7 @nacin
13 years ago

  • Milestone changed from Awaiting Triage to Future Release

#8 @wonderboymusic
10 years ago

  • Keywords close added; needs-patch removed

This appears to "work" now - wordpress/?color=blue&shade=yellow has color as taxonomy and blue as term

#9 @wonderboymusic
10 years ago

  • Keywords close removed
  • Milestone Future Release deleted
  • Resolution set to worksforme
  • Status changed from accepted to closed

Like I said, this appears to work - last activity was 3 years ago, and no one has commented since I tagged "close"

Note: See TracTickets for help on using tickets.