Created
February 25, 2015 11:01
-
-
Save tomazzaman/e661dd2a86a8f1857301 to your computer and use it in GitHub Desktop.
Add Jetpack Markdown support for ACF
This file contains 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
<?php | |
// Add these filters in functions.php | |
add_filter( 'meta_content', 'wptexturize' ); | |
add_filter( 'meta_content', 'convert_smilies' ); | |
add_filter( 'meta_content', 'convert_chars' ); | |
add_filter( 'meta_content', 'wpautop' ); | |
add_filter( 'meta_content', 'shortcode_unautop' ); | |
add_filter( 'meta_content', 'prepend_attachment' ); | |
// The rendering part | |
function render_acf() { | |
if( have_rows('flexible_content_field_name') ): | |
while ( have_rows('flexible_content_field_name') ) : the_row(); | |
if( get_row_layout() == 'content' ): | |
$content = get_sub_field( 'content' ); | |
// You might want to check whether WPCom_Markdown exists | |
$content = WPCom_Markdown::get_instance()->transform( $content , array( 'id' => false, 'unslash' => false ) ); | |
$content = apply_filters( 'meta_content', $content ); | |
echo $content; | |
endif; | |
endwhile; | |
else : | |
// no layouts found | |
endif; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment