Support » Fixing WordPress » 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)
  • Moderator Peter Westwood


    WordPress Lead Developer

    If you look at the codex page on 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.