So I limited the amount of characters per post via
the_excerpt('50') but it removes the image that I added to my post. How can I bring that image back so it shows up above the post then limits the characters?
The problem is that the_excerpt() strips all HTML. There's a good reason for this: what if the 49th word of a 50 word excerpt was the first word of a bulleted list? Or the second word in an
The way I would work around this is by using post thumbnails. These allow you to have an image you can choose to display at different sizes (or not at all) depending on the situation. I've often used them as small image queues above excepts which link to a full post. I would then insert a larger version of the image inside the post.
If your theme doesn't currently support post thumbnails, you can activate them by adding:
where the arguments are: name, width, height, and crop. Here's the reference. I've made the height "999" here because I only really care about the width being a certain amount. Afterward, you can then call:
inside of your theme to display it when you're in the loop.
If you need more than one thumbnail, you can use something like the Multiple Post Thumbnail plugin. I've used it a few times, and it's worked quite well for me.
Gavin is totally right about the excerpt needing to strip html, but sometimes you really do want to keep some of that html. Then what?
I wrote an excerpter that preserves key html tags. You can find it here: Limit to a certain number of characters in excerpt, but keep html tags and only whole words
And maybe you have some suggestions to make it better?