Make WordPress Core

Opened 9 years ago

Closed 9 years ago

#32919 closed enhancement (duplicate)

Add post_type argument to get_tags function

Reported by: atomicjack's profile atomicjack Owned by:
Milestone: Priority: normal
Severity: normal Version: 4.2.2
Component: Taxonomy Keywords:
Focuses: Cc:

Description

Hi,

Some changes would need to be incorporated to make this possible - but it would be a good idea to add a post_type argument to the get_tags function, so that we can get a list of tags that is used on a specific post type.

This would allow us to filter a certain post type's search results for a specific tag.

Change History (3)

#1 @swissspidy
9 years ago

This is currently possible using a filter, as per this answer on WPSE.

Not sure if this something that should be included in core as I haven't seen many use cases for it. Usually CPTs have their own taxonomy and don't use tags.

If it's suitable for core, then the change should probably be made in get_terms, not get_tags.

#2 @atomicjack
9 years ago

Either get_terms or get_tags would satisfy, just so as long as it would be, by core, possible to filter a post_type by tags.

An example use case: you have a main search form, then a 'filter', you want to display the available tags for that post_type in a dropdown, so that the user can select a post from that post_type using tags.

There might not be many use cases - but being able to filter a result via it, or display a filter box, would be very handy, particularly so for more corporate sites using WordPress, in which lots of content may be present.

#3 @boonebgorges
9 years ago

  • Milestone Awaiting Review deleted
  • Resolution set to duplicate
  • Status changed from new to closed

Duplicate of #18106.

Thanks for the suggestion and welcome to Trac, atomicjack. The short reason why we can't do this is that tags are a property of posts, not the other way around. For more detail, see https://core.trac.wordpress.org/ticket/18106#comment:7.

Note: See TracTickets for help on using tickets.