-
-
Save schurpf/50fc8d1f9457dd37a366 to your computer and use it in GitHub Desktop.
php: wrap acf fields with barley editor
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* 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