91 posts
  • Bought between 100 and 499 items
  • Exclusive Author
  • Has been a member for 5-6 years
  • Sold between 100 and 1 000 dollars
  • United States
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
  • United States
  • Attended a Community Meetup
  • Author had a Free File of the Month
  • Bought between 50 and 99 items
  • Repeatedly Helped protect Envato Marketplaces against copyright violations
  • Has been a member for 5-6 years
  • Contributed a Tutorial to a Tuts+ Site
  • Contributed a Blog Post
+4 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
  • Bought between 100 and 499 items
  • Exclusive Author
  • Has been a member for 5-6 years
  • Sold between 100 and 1 000 dollars
  • United States
cdogmx says

Thanks! booomarked the function reference. Much appreciated

by
by
by
by
by
by