WordPress.org

Forums

limiting words shown in the_content (5 posts)

  1. hbalagh
    Member
    Posted 6 years ago #

    I know that i can use the exceprt, how ever you loose all formatting and the image of the book cover is no longer displayed. I want to use the content for one small area on my homepage that displays a recommended book you can see it at http://www.bpdfriends.com/ on on the right hand side. So I just want to limit the words for that particular area no where else...

  2. kymac
    Member
    Posted 6 years ago #

    Not a very slick solution, but you could make a second post with just the text you want. Display that one in the sidebar and link it to the full post.

  3. hbalagh
    Member
    Posted 6 years ago #

    the info that is posted there is automatic so i can't really do that

  4. offspring
    Member
    Posted 6 years ago #

    I think you can use get_the_content() to get the content into string variable and then truncate the string to whatever length you wish.
    You may want to read this http://codex.wordpress.org/Function_Reference/get_the_content and this http://codex.wordpress.org/Template_Tags/the_content

  5. rane23
    Member
    Posted 6 years ago #

    I found this excerpt function: http://bavotasan.com/tutorials/limiting-the-number-of-words-in-your-excerpt-or-content-in-wordpress/ which lets you set the length of the excerpt by using <?php excerpt('N'); ?> to whatever number you'd like.

Topic Closed

This topic has been closed to new replies.

About this Topic