WordPress.org

Ready to get started?Download WordPress

Forums

Using Tag as a Variable (2 posts)

  1. jzader
    Member
    Posted 8 years ago #

    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!

  2. 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.

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags