SitePoint Sponsor |
|
User Tag List
Results 1 to 4 of 4
-
Oct 13, 2008, 03:51 #1
- Join Date
- Aug 2008
- Location
- Turkey
- Posts
- 26
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Getting Post's Tags on Wordpress Without Use Loop
Hello.
How i can get post's tags on Wordpress without use loop? I think i can get tags from through DB but i don't know how i can do this.
Thanks.
-
Oct 14, 2008, 01:21 #2
- Join Date
- Aug 2000
- Location
- Philadephia, PA
- Posts
- 20,578
- Mentioned
- 1 Post(s)
- Tagged
- 0 Thread(s)
There's a (not well documented) function you can use to get the tags for a post by ID: wp_get_post_tags($id). This returns an array of tag objects. To get the ones you're probably looking for in text:
PHP Code:$existing_tags = wp_get_post_tags($post->ID);
$tags = array();
if (count($existing_tags) > 0) {
foreach ($existing_tags as $tag) {
if ($tag->taxonomy == 'post_tag')
$tags[] = $tag->name;
}
}
//now use $tags array of tag names
Last edited by Dan Grossman; Oct 14, 2008 at 03:42. Reason: Added more info
Try Improvely, your online marketing dashboard.
→ Conversion tracking, click fraud detection, A/B testing and more
-
Oct 14, 2008, 03:51 #3
- Join Date
- Aug 2008
- Location
- Turkey
- Posts
- 26
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Ah thanks. It's worked perfectly.
-
Oct 16, 2008, 04:42 #4
Thanks a lot for your valuable input... It is really works fine.
Bookmarks