Ticket #6590 (closed enhancement: fixed)

Opened 6 months ago

Last modified 4 months ago

Add has_tag function to determine if a post has a given tag

Reported by: Otto42 Assigned to: anonymous
Priority: normal Milestone: 2.6
Component: Template Version:
Severity: normal Keywords: has-patch 2nd-opinion has_tag tag
Cc:

Description

As discussed on wp-hackers, this is a patch for a "has_tag" function. New Loop function which takes a tag slug, id, or name (or array of such) and returns true if the post has that tag, false if it doesn't. Also takes a null input and returns true if the post has any tag.

Useful for theme developers to produce different things depending on tags. Compare to "in_category", as this is basically the same thing but for tags.

Patch for trunk attached.

Attachments

has-tag.diff (1.4 kB) - added by Otto42 on 04/04/08 18:16:43.
Add has_tag function.
has-tag.2.diff (1.2 kB) - added by Otto42 on 04/21/08 16:46:02.
Updated function to handle no tag case better

Change History

04/04/08 18:16:43 changed by Otto42

  • attachment has-tag.diff added.

Add has_tag function.

04/05/08 01:06:28 changed by ozh

  • keywords set to has-patch 2nd-opinion has_tag tag.

04/21/08 16:46:02 changed by Otto42

  • attachment has-tag.2.diff added.

Updated function to handle no tag case better

06/20/08 13:52:18 changed by westi

  • status changed from new to closed.
  • resolution set to fixed.

(In [8131]) Add new has_tag() template tag. Fixes #6590 props Otto42.