Skip to content

Instantly share code, notes, and snippets.

@tomazzaman
Created February 25, 2015 11:01
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tomazzaman/e661dd2a86a8f1857301 to your computer and use it in GitHub Desktop.
Save tomazzaman/e661dd2a86a8f1857301 to your computer and use it in GitHub Desktop.
Add Jetpack Markdown support for ACF
<?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