X

Split WordPress Custom Field Values

We have been aware of WordPress’ Post Thumbnail Feature for a while now, but in some cases one is just not enough. This is a cool snippet for expanding WordPress’ post thumbnail output with the help of custom fields to add more thumbnails.

We have been aware of WordPress’ Post Thumbnail Feature for a while now, but in some cases one is just not enough. This is a cool snippet for expanding WordPress’ post thumbnail output with the help of custom fields to add more thumbnails. Although there are plugin alternatives, this is a very quick method for something simple, short and sweet.

So lets say you have a portfolio page and you want to display a couple of thumbnails, say 4(or more). This is what you can do:

Create a custom field value of Images and in the textarea insert the links to your images. Each link MUST be on a new line. Then use this snippet.

The code above converts each new line to HTML’s <br /> tag and explodes this into an array containing the links to the images. You can then use a foreach loop to display these.

Comments  Leave a Reply

Add a Comment

We're glad you have chosen to leave a comment. Please keep in mind that all comments are moderated according to our privacy policy, and all links are nofollow. Do NOT use keywords in the name field. Let's have a personal and meaningful conversation.

WordPress Launch Checklist

The Ultimate WordPress Launch Checklist

We've compiled all the essential checklist items for your next WordPress website launch into one handy ebook.
Yes, Send Me the Free eBook!