I’m looking to create a portfolio using a WordPress blog. On the summary page for the “blog posts” I want there to be thumbnails of images, and then obviously when you click into these they will go to the full listing for that project.
I figure that I could restrict the posts on the summary page, just to show one image from the description.
My idea is as follows:
Post name: Project
Description: <img class="thumbnail-image" /> <img /> <img /> <img /> <p></p>
On the summary page I would like the loop just to target and display the image with the class of “thumbnail-image” in each post, and then in the single post page I will hide the thumbnail image using CSS.
What I would like to know is whether there is a good way in php of detecting that first image element from the description and extracting it from the description so that I can display it on the summary page?
I figured it out in the end:
In my limited knowledge of PHP (learned over the last few days) it seems that
the_content()is used more to PUBLISH the value of the post’s content and any mention ofthe_content()in the code will publish the content contained therein. To target and play with the value further you have to be more specific, ie$post->post_content(targetting the post content of the post).