Skip to content

Instantly share code, notes, and snippets.

@ammist
Last active July 13, 2016 01:59
Show Gist options
  • Save ammist/c20b37853ab80f1e14b5ca457fa916cc to your computer and use it in GitHub Desktop.
Save ammist/c20b37853ab80f1e14b5ca457fa916cc to your computer and use it in GitHub Desktop.
ACF Fields in HTML Example with genesis tempate
<?php
/*
* Displays in a list form an ACF repeater field with three subfields
* Field: urls
* Sub-FieldS: label, link, style,
*
*/
$post = get_queried_object();
if (have_rows('urls', $post->ID)){ // we have some url's
echo '<ul class="profile-links">'; // open a list because we have something to show
while(have_rows('urls', $post->ID)){
the_row();
echo '<li><a class="fa '.get_sub_field('style').'" href="'.get_sub_field('link').'">'.get_sub_field('label').'</a></li>';
}
echo "</ul>"; // close the list of URL's
}
// here's an array field (checkboxes)
$work = get_field('work_availability');
// The following lines represent a way for you to see what's in your fields
echo "<pre>";
var_dump($work);
echo "</pre>";
// check to make sure there's content in here
if (is_array($work)){
echo "<h4>Work Availability</h4>";
echo "<ul>";
foreach($work as $w){
echo "<li>$w</li>";
}
echo "</ul>";
}
<?php
function show_my_fields(){
?>
<div class="field1">One field: <?php the_field('fieldname');?></div>
<?php
// If you put your template part in the same directory as the template file...
get_template_part('profile-summary');
}
add_action('genesis_entry_content', 'show_my_fields', 15);
genesis();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment