I've created a custom metabox with a textarea in it. How would I go about using Markdown in this textarea? I've seen some WP plugins but they seem to only be for the main editor.

3 Answers 3


You can download a copy of PHP Markdown and use it to parse the textarea contents before you save it:

if ( ! class_exists( 'Markdown' ) ) {
    require_once( plugin_dir_path(__FILE__) . '/markdown.php' );
$textarea_contents = Markdown::defaultTransform( $textarea_contents );

I installed ACF Custom Field WYSIWYG and Markdown Extra.

In functions.php, add code:

remove_filter( 'acf_the_content', 'wpautop' );
remove_filter( 'acf_the_content', 'wptexturize' );
add_filter( 'acf_the_content', 'Markdown' );

Every custom post field that uses acf_the_content will convert to Markdown. You can use the main content too:

add_filter( 'the_content', 'Markdown' );

The best Markdown parser I've found so far is the Parsedown. Something like this:

if ( ! class_exists( 'Parsedown' ) ) {
    require_once( get_template_directory() . '/Parsedown.php' );

$parsedown = new Parsedown();
echo $parsedown->text( $content );

If you are dealing with a client this is the way to go, Parsedown is almost bulletproof.

  • 2020 : Thanks man ...
    – MarcoZen
    Commented Jun 4, 2020 at 17:56

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.