0

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 2

1

You can try remove_filter( 'the_content', 'wpautop' ); to remove the added HTML tags.

https://codex.wordpress.org/Function_Reference/wpautop

2
  • Where do I put this code? Please, for someone that is not a WP expert this is not obvious...
    – Operator
    Jan 1, 2021 at 21:32
  • 1
    Per 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.
    – mzykin
    Jan 3, 2021 at 18:36
0

You have to do two things

  1. Completely disable visual editor
  2. 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

2
  • 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?
    – GWorking
    Jan 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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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