12% off of LTD using this coupon: TWELVEPERCENTOFF. Promo ends on 2 Dec midnight UTC.
Published on May 2, 2024

ACF Gallery Image URL by Index in Oxygen

Sridhar Katakam

This Premium tutorial provides the steps to set an image specified by its index from a ACF Pro Gallery-type field for Pages as the background of the hero section for Pages in Oxygen.

ACF Field Group:

Field being populated on a Page:

After implementing the tutorial, 2rd image (Index = 1) as Hero section background on the Front end:

3rd image (Index = 2) as Hero section background on the Front end:

Step 1

Add a new field group for your post type.

Ex.: "Page Fields" for Pages.

Add a Gallery-type of field.

Sample field name: hero_background

Leave the Return Format the default 'Image Array'.

Step 2

Edit your posts (Pages, in this example) and populate the field for each.

Step 3

Create a custom function named say, "Get a image URL from ACF Gallery by index" having this code using a code snippets plugin:

This is a premium members-only content.

To view the rest of the content, please sign up for membership ($47/month or $599 one-time).

Already a member? Log in below or here.