Title: Remove post_markdown2html
Last modified: March 16, 2023

---

# Remove post_markdown2html

 *  Resolved [Dennish Karki](https://wordpress.org/support/users/karkidennis/)
 * (@karkidennis)
 * [3 years, 2 months ago](https://wordpress.org/support/topic/remove-post_markdown2html/)
 * I just want the markdown output. How should I disable the post_markdown2html

Viewing 5 replies - 1 through 5 (of 5 total)

 *  Plugin Author [Pierre-Henri Lavigne](https://wordpress.org/support/users/peter202202/)
 * (@peter202202)
 * [3 years, 2 months ago](https://wordpress.org/support/topic/remove-post_markdown2html/#post-16565080)
 * [@karkidennis](https://wordpress.org/support/users/karkidennis/) I guess you 
   can’t. At the moment of writing you can access “staticly” the PHP instance’s 
   properties & methods through the global “mmd” function but not the instance itself
   so you won’t be able to remove the filter. Time for a new feature ? 🙂 
   Anyway
   I setup the filter to “the_content” function so if you want the raw source code,
   you can still use “get_the_content”. For example if your theme’s template instead
   of writing :
 *     ```wp-block-code
       the_content();
       ```
   
 * If you write :
 *     ```wp-block-code
       echo get_the_content();
       ```
   
 * The markdown version should popup 😉 Tell me if that helps
 *  Thread Starter [Dennish Karki](https://wordpress.org/support/users/karkidennis/)
 * (@karkidennis)
 * [3 years, 2 months ago](https://wordpress.org/support/topic/remove-post_markdown2html/#post-16565387)
 * Actually, I want the raw content in API Like this [https://prnt.sc/craHr8qCrUbx](https://prnt.sc/craHr8qCrUbx)
   I have this after I commented the filter [https://prnt.sc/9uiSQBfVbl-a](https://prnt.sc/9uiSQBfVbl-a)
   
   Any Suggestions for doing this without modifying the Plugin? Or as you mentioned`
   get_the_content()` will output the raw then I can add the custom field in API.
    -  This reply was modified 3 years, 2 months ago by [Dennish Karki](https://wordpress.org/support/users/karkidennis/).
 *  Plugin Author [Pierre-Henri Lavigne](https://wordpress.org/support/users/peter202202/)
 * (@peter202202)
 * [3 years, 2 months ago](https://wordpress.org/support/topic/remove-post_markdown2html/#post-16565921)
 * [@karkidennis](https://wordpress.org/support/users/karkidennis/) yeah I have 
   to add a new setting / constant so developer can freely switch off the filter
   regards to their needs.
   I’m busy right now but will definitively take a look 
   this week-end.If you only target the API, you should be able to use the appropriate
   filters without modifying the plugin. For exemple :
 *     ```wp-block-code
       function raw_markdown_code( $data, $post, $request ) {
       	# Replace the html formated content via original markdown saved in database
       	$data->data[ 'content' ] = $post->post_content;
       	return $data;
       }
       add_filter( 'rest_prepare_post', 'raw_markdown_code', 10, 3 );
       ```
   
 * You still need to modify the snippet for your needs 😉
 *  Thread Starter [Dennish Karki](https://wordpress.org/support/users/karkidennis/)
 * (@karkidennis)
 * [3 years, 2 months ago](https://wordpress.org/support/topic/remove-post_markdown2html/#post-16568227)
 * [@peter202202](https://wordpress.org/support/users/peter202202/) Thanks man. 
   It is what I need.
 *  Plugin Author [Pierre-Henri Lavigne](https://wordpress.org/support/users/peter202202/)
 * (@peter202202)
 * [3 years, 2 months ago](https://wordpress.org/support/topic/remove-post_markdown2html/#post-16580527)
 * [@karkidennis](https://wordpress.org/support/users/karkidennis/) Glad it’s working
   mate 🙂
 * I’ve just released v1.8.1 with the WP_MMD_RAW_DATA constant so you can disable
   the filter through a specific “loading”* hook of your choice.
    1. For example you can add the following snippet inside you wp-config.php to disable
       globally the html output :
       `define( 'WP_MMD_RAW_DATA', 1 );`
    2. Or inside a hook from your child’s theme functions.php file :
       `add_action('init',
       function() { if ( ... ) { define( 'WP_MMD_RAW_DATA', 1 ); } }); `
 * The side effect with the REST API is that the related hooks or constants like
   REST_REQUEST created by WordPress are setup at the beginning of the “processing”*
   stage, just after the “loading”* stage has finished, which is too late.
 * To make it short it will remain a specific case with the current plugin’s structure
   and to avoid “delicate” modifications or unwanted side effects, the best way 
   to target the REST API – with other plugins as well to my mind – is still the
   use of the snippet provided last week or a variant like the following one :
 *     ```wp-block-code
       add_action( 'rest_api_init', function() {
       	remove_all_filters( 'the_content' );
       	remove_all_filters( 'the_excerpt' );
       });
       ```
   
 * *By _loading_ and _processing_ I’m referring to this chart :
   [https://blog.lancecleveland.com/2017/10/11/wordpress-hooks-and-filters-order-of-precedence/](https://blog.lancecleveland.com/2017/10/11/wordpress-hooks-and-filters-order-of-precedence/)
 * I hope the explanations / reference is gonna inspire you, and if you don’t mind
   I’m gonna mark the issue as resolved 👍

Viewing 5 replies - 1 through 5 (of 5 total)

The topic ‘Remove post_markdown2html’ is closed to new replies.

 * ![](https://ps.w.org/markup-markdown/assets/icon.svg?rev=2691249)
 * [Markup Markdown](https://wordpress.org/plugins/markup-markdown/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/markup-markdown/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/markup-markdown/)
 * [Active Topics](https://wordpress.org/support/plugin/markup-markdown/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/markup-markdown/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/markup-markdown/reviews/)

## Tags

 * [markdown](https://wordpress.org/support/topic-tag/markdown/)

 * 5 replies
 * 2 participants
 * Last reply from: [Pierre-Henri Lavigne](https://wordpress.org/support/users/peter202202/)
 * Last activity: [3 years, 2 months ago](https://wordpress.org/support/topic/remove-post_markdown2html/#post-16580527)
 * Status: resolved