Skip to content

Instantly share code, notes, and snippets.

@kamlekar
Forked from alenabdula/Instructions.md
Created October 24, 2017 11:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kamlekar/9d5e6cb6fe0a73c9a0d4d18dba1d9c15 to your computer and use it in GitHub Desktop.
Save kamlekar/9d5e6cb6fe0a73c9a0d4d18dba1d9c15 to your computer and use it in GitHub Desktop.
Using Custom Fields Suite to Create Gallery Loop, See: https://css-tricks.com/forums/topic/multiple-images-wordpress-custom-fields

##Setting Up Meta Data Fields##

  • Install/Activate Custom Fields Suite WordPress Plug-In, Docs
  • Create new Field Group called Gallery Meta Data
  • Add a Field called Gallery Images and set the type as Loop, fill out the rest of the required fields, for placement rules attach this custom meta data to WordPress type of Page or whatever your requirements are. Hit Publish Figure 1
  • Next, Add additional field called Image. Hit Update Figure 2
  • Next, drag Image, field we just created, under the Gallery Images it needs to be a child of the Loop, Hit Update Figure 3

##Adding Meta Data to Pages##

  • Edit page you wish to add the Gallery Images to Figure 4
  • Keep hitting Add Image to add additional images Figure 5

##Getting the Data##

  $gallery_images = CFS()->get('gallery_images');
  foreach ($gallery_images as $image) {
    echo '<img src="'.$image["image"].'"/>';
  }

Note: for get('gallery_images'), gallery_images is the value that matches the value specified in our initial setup of Custom Meta Data fields. See Figure 6

##Figures##

Figure 1

Figure 2

Figure 3

Figure 4

Figure 5

Figure 6

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment