Skip to content

Instantly share code, notes, and snippets.

@scottnix
Created June 21, 2013 03:53
Show Gist options
  • Save scottnix/5828672 to your computer and use it in GitHub Desktop.
Save scottnix/5828672 to your computer and use it in GitHub Desktop.
Thematic and ACF example. Uses custom fields, a conditional and set on a hook that is inside the loop.
// example of using ACF custom fields, with conditionals
// this has to be set inside the loop, not sure how to place one anywhere yet (haven't needed it)
function childtheme_acf_additions() {
if (is_single()) { ?>
<ul class="toggle-specs c-engine">
<h3 class="expand">Engine Specs <i class="">+</i></h3>
<div class="panel">
<?php
if(get_field('c_engine')) {
echo '<li><span>Engine:</span> ' . get_field('c_engine') . '</li>';
}
if(get_field('c_compression')) {
echo '<li><span>Compression:</span> ' . get_field('c_compression') . '</li>';
}
if(get_field('c_stroke')) {
echo '<li><span>Stroke:</span> ' . get_field('c_stroke') . ' and <span>Bore</span> ' . get_field('c_bore') . '</li>';
}
if(get_field('c_heads')) {
echo '<li><span>Heads:</span> ' . get_field('c_heads') . '</li>';
}
?>
</div>
</ul> <?php
}
else {
echo '<h3>No Engine Spec Details Available</h3>';
}
}
add_action('thematic_belowpost', 'childtheme_acf_additions');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment