Title: Using Tag as a Variable
Last modified: August 18, 2016

---

# Using Tag as a Variable

 *  [jzader](https://wordpress.org/support/users/jzader/)
 * (@jzader)
 * [20 years, 10 months ago](https://wordpress.org/support/topic/using-tag-as-a-variable/)
 * I need to use a tag (e.g., `single_post_title()`) as a traditional variable (
   e.g., `$single_post_title`) but I can’t figure out how to do it.
 * (It has to be a variable so that I can pass it through to a template coming from
   outside the WordPress software.)
 * What’s the trick?
 * I’ve searched the Codex and Support forums extensively, but I’m not having any
   luck finding an answer.
 * Thanks in advance for any help!

Viewing 1 replies (of 1 total)

 *  [Peter Westwood](https://wordpress.org/support/users/westi/)
 * (@westi)
 * [20 years, 10 months ago](https://wordpress.org/support/topic/using-tag-as-a-variable/#post-244976)
 * If you look at the codex page on [single_post_title()](http://codex.wordpress.org/Template_Tags/single_post_title)
   then we can see that it takes two arguments. The first is a `prefix` to display
   before the title and the second is a `Boolean` which tells the template tag wether
   to echo the text stratight out or return it to be used by some php code.
 * Therefore you want something like this:
    ` <?php $single_post_title = single_post_title('
   prefix', FALSE);?>
 * Hope this helps.

Viewing 1 replies (of 1 total)

The topic ‘Using Tag as a Variable’ is closed to new replies.

## Tags

 * [as](https://wordpress.org/support/topic-tag/as/)
 * [tag](https://wordpress.org/support/topic-tag/tag/)
 * [variable](https://wordpress.org/support/topic-tag/variable/)

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 1 reply
 * 2 participants
 * Last reply from: [Peter Westwood](https://wordpress.org/support/users/westi/)
 * Last activity: [20 years, 10 months ago](https://wordpress.org/support/topic/using-tag-as-a-variable/#post-244976)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
