WordPress.org

Make WordPress Core

Opened 9 years ago

Closed 9 years ago

Last modified 5 years ago

#14589 closed enhancement (fixed)

tags doesn't list other post types

Reported by: vteixeira Owned by:
Milestone: 3.1 Priority: normal
Severity: normal Version: 3.0.1
Component: Query Keywords:
Focuses: Cc:

Description

I registered the post_tag taxonomy to other post types I have created.
Ok, it appears on thi post types screen and I can create tags for this post types without problems.

The problem is: when I go to the front end and try something like mydomain.com/tag/test/ it just display posts with the 'test' tag, not other post-types.

Am I missing something here or is this really a bug?

Change History (11)

#1 @scribu
9 years ago

  • Component changed from Taxonomy to Query

It's a bug. A workaround would be:

`
function post_type_tags_fix($request) {

if ( isset($requesttag?) && !isset($request['post_type]) )

$request['post_type] = 'any';

return $request;

}
add_filter('request', 'post_type_tags_fix');
`

#2 @scribu
9 years ago

Ah, disregard the beginning and ending `.

#3 @nacin
9 years ago

I wouldn't mind making it so you can easily trigger more/all post types to appear in various locations in a future release, of course, but I don't think this is a 'bug'. We deliberately didn't set up other post types to appear in the front-end, including categories, tags, index pages, feeds, archives, what have you... By default, post type of 'post' is assumed. You then have to manipulate further.

#4 @vteixeira
9 years ago

  • Cc vteixeira added

Scribu: thanks for the workaround. I'll test this.

Nacin: I understand, but if I'm registering the tags taxonomy to a post type it's because I want this post type listed on the tags taxonomy.
If it's not listed by default I don't see why I'm able to register the built in taxonomies to other post types.

I think this is the expected behavior: if I can attach tags to other post types then this post types will appear when I list those tags...

I think it's really a bug, not some enhancement to be considered for a future release.

#5 @nacin
9 years ago

  • Type changed from defect (bug) to feature request

What we currently have is intended behavior from a development and roadmap standpoint. This is not a bug.

You're able to register taxonomies for other post types but using a post type is not just about registration. You also have to implement it to your liking.

There are plenty of use cases where this is not optimal, so when we do this it will only be an option, not a default.

#6 @scribu
9 years ago

  • Type changed from feature request to enhancement

We deliberately didn't set up other post types to appear in the front-end, including categories, tags, index pages, feeds, archives, what have you... By default, post type of 'post' is assumed.

That's not entirely true. When going to /custom-taxonomy/term the post type is automatically set to 'any'. So it's a bug in the sense that the tag taxonomy doesn't behave like custom taxonomies.

#7 @vteixeira
9 years ago

Nacin: please tell me what use case is this where someone register a taxonomy for a post type and when I click on the taxonomy item I don't see it listed. I can't think of any use case.

If I don't want the post type to be listed for that taxonomy it's because I don't want the taxonomy registered for that post type at all.

As Scribu said above, for any other taxonomy that I register it just works. I get all post types that are registered for this taxonomy listed, why tags are different?

Please clarify that. Maybe it's not a bug but this was not implemented correctly.

#8 @vteixeira
9 years ago

Hi, just a follow up.
I got it working with this code:

function post_type_tags_fix($request) {
	if ( isset($request['tag']) && !isset($request['post_type']) )
	$request['post_type'] = 'any';
	return $request;
} 
add_filter('request', 'post_type_tags_fix');

But I still think it should be the default behavior.

#9 @scribu
9 years ago

  • Milestone changed from Awaiting Review to 3.1
  • Resolution set to fixed
  • Status changed from new to closed

#10 @scribu
9 years ago

(In [15650]) Consistently set $post_type to 'any' when a taxonomy query is involved. See [15649]. See #14589

#11 @johnbillion
5 years ago

Subsequent discussion: #19471

Note: See TracTickets for help on using tickets.