Conditionally Display 1st Attachment Image From Post Content On Archives Instead of Featured Image

By default, Genesis displays the featured on archives according to your Genesis > Theme Settings > Content Archive settings.

content-archives

What if you don’t want to use the featured image and prefer to use the 1st attached image?

The code in this tutorial uses the first image added to the post content which is known as the first-attached image.

You can modify the conditional tag to show the first attached image on any archive type including any blog listings page, including archive, author, blog, category, search, and tag pages.

The following solution has been hand coded in response to the following question from a member of the StudioPress Community:

Is there a way to have the post image instead of the feature image appear on a category page? So I want the feature image to show on the home page (which it is now and that’s fine) but on the category page I want the post image to show.

Here’s the code for logged in members:

Join 5000+ Followers

Get The Latest Free & Premium Tutorials Delivered The Second They’re Published.