[resolved] Why do template tags not allow being returned? (3 posts)

  1. jakeisonline
    Posted 6 years ago #

    I find it very irritating that you can't define all tags to be returned rather than echoed.

    I'm trying to re-work how comments are being processed in my theme, and now I can't because I can't return simple tags like comment_ID or comment_text - it's not exactly hard to flag all tags with a true/false boolean to determine if the call wants it to be returned as echo or return does it?

  2. jakeisonline
    Posted 6 years ago #

    Damn, Google pulled through for me a little too late.

    This is badly documented, but appending get_ to the beginning of a template tag will return it rather than echoing it.


    foreach ($comments as $comment) {
       $get_comment_id // Will return the ID, but not print it to the page
       $comment_id // Will print it to the page, rather than return it.
  3. t31os
    Posted 6 years ago #

    Handy to know, thanks for posting back your findings, i can't say i would have realised that without you clearly explaining what you wanted and the difference between the 2.

    Not something that will help me at the moment but i had noticed the functions were printing the values rather then returning them.

    Thanx it will come in handy i'm sure.

Topic Closed

This topic has been closed to new replies.

About this Topic