WordPress.org

Make WordPress Core

Opened 4 years ago

Closed 9 months ago

#12719 closed enhancement (worksforme)

Custom taxonomy with query_var set, gets taxonomy query_var appended anyway

Reported by: Silkjaer Owned by: 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)

comment:1 dd324 years ago

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

comment:2 dd324 years ago

  • Component changed from Query to Canonical

comment:3 dd324 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.

comment:4 Silkjaer4 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
		)
	);

comment:5 dd324 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.

comment:6 nacin4 years ago

There is another ticket around to add something similar

#9951

comment:7 nacin3 years ago

  • Milestone changed from Awaiting Triage to Future Release

comment:8 wonderboymusic9 months 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

comment:9 wonderboymusic9 months 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.