WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] Auto Add Read More (5 posts)

  1. drewbotts
    Member
    Posted 3 years ago #

    I am looking for a way to automatically add a "read more" after a specific character count. I have tried using the_excerpt() but I need something that will support images and html in order to style the "read more" text. I have seen plugins, but I cannot find one that works with wordpress 3.2.1. Any ideas?

    Thanks,
    Drew

  2. John Hawkins
    Member
    Posted 3 years ago #

    Hey Drew. That may get a little dicey when it comes to including images and such because an image tag can contain a huge amount of characters. Especially if it includes an alt or title tag. If you use a character count and it cuts off in the middle of an image, you may end up with something really strange.

    But, that being said, you may be able to try something like substr(the_content(), 0, 100). It may give you what you are looking for.

    Please try that on a development site first.

  3. alchymyth
    Forum Moderator
    Posted 3 years ago #

    something that will support images and html in order to style the "read more" text

    you can do this with the_excerpt():

    http://codex.wordpress.org/Function_Reference/the_excerpt
    just work from this general method:
    http://codex.wordpress.org/Function_Reference/the_excerpt

  4. drewbotts
    Member
    Posted 3 years ago #

    Thanks, for both of your inputs. Sorry its taken so long for me to reply (busy week). I am going to try your suggestions tonight and I'll let you know how it turns out.

    Thanks again

    Drew

  5. drewbotts
    Member
    Posted 3 years ago #

    I used the_excerpt() and after a little bit of research I got it to do exactly what I needed it to. In order to customize the "read more" look I followed the link @alchymyth suggested:
    http://codex.wordpress.org/Function_Reference/the_excerpt

    In order to allow images to be displayed I had to edit the formatting.php file with some help from this site:
    http://www.milienzo.com/2007/09/02/improving-wordpress-the_excerpt-template-tag/

    thanks for all the help!

    Drew

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.