Wordwrap issues - wordpress blog

Discussion in 'PHP' started by BigJonnyB, Jun 7, 2009.

  1. #1
    Any ideas why my wordwrap isn't working. If I just use plain text instead of calling the title it works fine. The title is displaying property but not wrapping.

    <?php $strr = the_title(); echo wordwrap($strr, 10, "<br />\n"); ?>

    I have tried all kinds of alternatives but I'm still learning with PHP.

    Thanks
     
    BigJonnyB, Jun 7, 2009 IP
  2. dean5000v

    dean5000v Peon

    Messages:
    201
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #2
    give it a class and add some css styling to wordwrap the text
     
    dean5000v, Jun 7, 2009 IP
  3. SHOwnsYou

    SHOwnsYou Peon

    Messages:
    209
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    0
    #3
    I don't think you want to echo the wordwrap command.
     
    SHOwnsYou, Jun 7, 2009 IP
  4. Cash Nebula

    Cash Nebula Peon

    Messages:
    1,197
    Likes Received:
    67
    Best Answers:
    0
    Trophy Points:
    0
    #4
    Try this:
    <?php $strr = the_title(,,FALSE); echo wordwrap($strr, 10, "<br />\n"); ?>

    You need the FALSE to use it with PHP, because the default is TRUE:
    http://codex.wordpress.org/Template_Tags/the_title

    Also, it needs to be inside the Wordpress loop. Use get_the_title(ID) when outside of the loop.
     
    Cash Nebula, Jun 7, 2009 IP