How to get tags and categories?


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?

, , , Liwii 7 years 0 Answers 77 views 0

Leave an answer