Hi Guys,
I am using this code to get the tags in my wordpress posts for a theme
`<?php
$posttags = get_the_tags();
if ($posttags) {
foreach ($posttags as $tag) {
$tagnames[count($tagnames)] = $tag->name;
}
$comma_separated_tagnames = implode(", ", $tagnames);
print_r($comma_separated_tagnames);
}
?>`
The PROBLEM is that it is returning tags for "all posts" not just individual posts, and I think the problem is that if a post DOESNT have tags - it just inserts tags anyway.
Can anyone help modify this so:
- It return tags only for a post - not all tags
- If there are no tags for a post, dont return anything
? Really appreciate any help