I used the following code to get tags from the post and then simply echo them:
$posttags = get_the_tags($post->ID);
if ($posttags) {
foreach($posttags as $tag) {
echo $tag->name . ', ';}
}
Now I need to get the categories as well. My first idea was to simply duplicate the function but isn't there a way to create one single function that'll retrieve both the tags and categories and then have it echo?
get_categories()
you could use maybe you can make a function and combine the two to return what you need.get_the_terms
. It runs filters and uses cache, whilewp_get_post_terms
is more internal method.