Skip to content

Instantly share code, notes, and snippets.

@schurpf
Forked from yratof/gist:4f312ae162f49876959c
Last active August 29, 2015 14:07
Show Gist options
  • Save schurpf/50fc8d1f9457dd37a366 to your computer and use it in GitHub Desktop.
Save schurpf/50fc8d1f9457dd37a366 to your computer and use it in GitHub Desktop.
php: wrap acf fields with barley editor
/**
* echo barley field with wrapper, use instead of the_field
* @author schurpf
* @url http://schurpf.com
* @version 0.1
* @date 2014-10-09
* @dependency barley, the_field_without_wpautop
* @param string $field_name your normal ACF field name
* @param boolean $noautop whether to omit wrapping p tags, needs the_field_without_wpautop
* @return none echos out content
* @source https://gist.github.com/yratof/4f312ae162f49876959c
*/
function barley_field($field_name, $noautop=False){
$key_values = get_post_custom_values( $field_name );
foreach ( $key_values as $key => $value ) {
if ( function_exists( 'barley_wrapper' )) {
echo barley_wrapper('wp_custom_field', $value , $field_name);
} elseif (function_exists( 'the_field' ) && $noautop && function_exists('the_field_without_wpautop')){
the_field_without_wpautop($field_name);
} elseif (function_exists( 'the_field' ) && !$noautop){
the_field($field_name);
} else {
echo $value;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment