Not sure if im going about this in the right way but, overall, ive been told to create, kind of like a news box on my home page and so, the “latest news” is going to be this clients posts.
now i know i can control the_excerpts();
content length etc but, i cant seem to find any way for it to also allow an image.
when i showed the client the “news box” he wants whatever image is associated with the post, to come through.
so i thought of "the_content();"
but i dont think thats what i need(though im not sure which one will work best with what i need)
so the main questions here for me are
- Can i somhow get the image to come through with the excerpt, or
- If the excerpt function doesnt allow it, then what can i use?
Ensure that your Theme supports Post Thumbnails, and that the client sets a “Featured Image” for each post. Then, combine
the_excerpt()
withthe_post_thumbnail()
, e.g. like so:Then, just use CSS to style according to your needs.
Have you tried using
get_the_post_thumbnail()
? You can read more about it on the Codex here. It pulls a thumbnail of the post’s featured image.Place this in your functions.php file:
This should preserve any images that occur within the content’s HTML before the Word Limit is reached.