How to get post tags as a PHP variable
-
Hi everyone,
I am trying to get my post tags as a php variable. What I want is to have them be something like this: $posttags = tag1&tag2&tag3&tag4
I need the ampersands between the tags because I am putting them into a Google search query URL. I’m able to echo the string that I want using the code below, but how do I store it as a variable? Thanks for any help you can provide!
$posttags = get_the_tags(); if ($posttags) { foreach($posttags as $tag) { echo $tag->name . '&'; } }
Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
The topic ‘How to get post tags as a PHP variable’ is closed to new replies.