91 posts
  • Has been part of the Envato Community for over 5 years
  • Has sold $100+ on Envato Market
  • Has collected 100+ items on Envato Market
  • Sells items exclusively on Envato Market
+1 more
cdogmx says

For example. I have a function like this.

function onit_format($content) {

    $formattedContent = str_replace('medium]', 'span]', $content);
    $formattedContent = str_replace('line2]', 'strong]', $formattedContent);

    echo $formattedContent;

}

Someone enters a post with the title of

Freebiesdock.com [line2][medium]freemium[/medium] wordpress theme[/line2]

Then in my template file I have this

<div class="title">&lt;?php onit_format(the_title()); ?&gt;</div>

I want this to be the output

<div class="title">Freebiesdock.com <strong><span>freemium</span> wordpress theme</strong></div>

But the text does not get formatted on output.

Is there a way to do this?

p.s. don’t pay attention to the actual coding of the function. I know it’s not right but I just want to know if there is a way to format a posts content on output.

Thanks!

2541 posts
  • Has referred 10+ members
  • Has sold $100+ on Envato Market
  • Has collected 50+ items on Envato Market
  • Located in United States
+9 more
CreatingDrew says

Yup, many functions come with an alias that returns the data instead of outputting it. The fact that wordpress doesn’t have functions just always return the values and let the dev echo it when desired is another story, but I digress ;)

For example, see get_the_title() http://codex.wordpress.org/Function_Reference/get_the_title

When in doubt, just search the codex for the function you’d like to return instead of output with a ‘get’ in front of it.

91 posts
  • Has been part of the Envato Community for over 5 years
  • Has sold $100+ on Envato Market
  • Has collected 100+ items on Envato Market
  • Sells items exclusively on Envato Market
+1 more
cdogmx says

Thanks! booomarked the function reference. Much appreciated

by
by
by
by
by
by