1

I have a dilemma, well a new blog which im developing and a few of the posts titles are like this 'Tutorial: Build your first App' or 'Tutorial: Start your business with xensuithia'

I have a page called tutorials that display the posts from this category.

I need the title to not display the 'Tutorial:' part on this page, I tried:

str_replace('Tutorial:',' ', the_title()); 

However it does not work. It just outputs the full title.

3
  • this is not a WordPress question at all. you need to do something like $cut_title = str_replace('Tutorial:',' ', the_title()); echo $cut_title; (I've flagged to close this question)
    – anu
    Commented Mar 31, 2011 at 14:21
  • grrr - as Markus points out, it should be get_the_title()
    – anu
    Commented Mar 31, 2011 at 14:29
  • 1
    Yeah, it is a WP question. It's about the_title() (and by inference, get_the_title(). Commented Mar 31, 2011 at 15:31

1 Answer 1

5

That's because the_title() echoes the title. Use this instead:

echo str_replace( 'Tutorial: ', '', get_the_title() );
2
  • None of these work :'( Commented Mar 31, 2011 at 14:27
  • What's the problem exactly?
    – Roomsick
    Commented Mar 31, 2011 at 14:33

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.