Skip to content

Instantly share code, notes, and snippets.

@Roy-Oto

Roy-Oto/loop.php Secret

Created April 29, 2021 01:28
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 Roy-Oto/42963a01dd3039f47016341fb551b0fd to your computer and use it in GitHub Desktop.
Save Roy-Oto/42963a01dd3039f47016341fb551b0fd to your computer and use it in GitHub Desktop.
To display Loop in Custom Field Suite.
<?php
/*
A loop field named "gallery" with sub-fields "slide_title" and "upload"
Loop fields return an associative array containing *ALL* sub-fields and their values
NOTE: Values of sub-loop fields are returned when using get() on the parent loop!
*/
$fields = CFS()->get( 'gallery' );
foreach ( $fields as $field ) {
echo $field['slide_title'];
echo $field['upload'];
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment