Is it possible to store posts in pure markdown format? so that I can retrieve the content through the REST API and get the markdown code, without any added html?
2 Answers
You can try remove_filter( 'the_content', 'wpautop' );
to remove the added HTML tags.
-
Where do I put this code? Please, for someone that is not a WP expert this is not obvious...– OperatorJan 1, 2021 at 21:32
-
1Per the referenced link, you'd put in your theme's functions.php file: Disabling the filter Some people choose to disable the wpautop filter from within their theme’s functions.php:
remove_filter( 'the_content', 'wpautop' ); remove_filter( 'the_excerpt', 'wpautop' );
There’s also a plugin available to enable/disable the filter on a post-by-post basis.– mzykinJan 3, 2021 at 18:36
You have to do two things
- Completely disable visual editor
- enable Markdown.
Disable Visual editor: Add this code in the themes function.php file or as a plugin.
add_filter( 'user_can_richedit' , '__return_false', 50 );
Enable Markdown: Install this plugin Wp-Markdown
-
With or without the plugin activated, if I paste markdown content on the post, I get paragraph html tags thorough the text. Indeed no difference with the plugin, maybe it's not working in the final WP version?– GWorkingJan 31, 2019 at 20:32
-
You must disable the richtext editor. Also wordpress has a function named "wpautop" which renders html <p> tag automatically. You have to disable that too. use this in your function file remove_filter( 'the_content', 'wpautop' ); remove_filter( 'the_excerpt', 'wpautop' ); Feb 3, 2019 at 13:14