enable markdown on wordpress with wp-cli

enable markdown on wordpress with wp-cli

I’m using wp-markdown plugin inside an auto generated wordpress site on docker.

Regularly, when I regenerate the site, I’m obligated to login each time to activate markdown manually.

To enable programmatically markdown features of this plugin, it’s so easy as update a worpdress option with wp-cli:

  • Inline command
wp option update markdown --format=json '{ "post_types" : { "0" : "post", "1" : "page",  "2" : "comment" }, "markdownbar" : { "0" : "posteditor", "1" : "comment" }, "prettify" : "0" }'
  • Using external file
wp option update markdown --format=json < markdown-option.txt

While markdown-option.txt contains:

{
  "post_types" :
    {
      "0" : "post",
      "1" : "page",
      "2" : "comment"
    },
  "markdownbar" :
    {
      "0" : "posteditor",
      "1" : "comment"
    },
  "prettify" : "0"
}
  • With docker exec (just skip double-quotes)
docker exec -ti --user www-data wordpress bash -c "wp option update markdown --format=json '{ \"post_types\" : { \"0\" : \"post\", \"1\" : \"page\",  \"2\" : \"comment\" }, \"markdownbar\" : { \"0\" : \"posteditor\", \"1\" : \"comment\" }, \"prettify\" : \"0\" }'"
admin

Leave a Reply

To create code blocks or other preformatted text, indent by four spaces:

    This will be displayed in a monospaced font. The first four 
    spaces will be stripped off, but all other whitespace
    will be preserved.
    
    Markdown is turned off in code blocks:
     [This is not a link](http://example.com)

To create not a block, but an inline code span, use backticks:

Here is some inline `code`.

For more help see http://daringfireball.net/projects/markdown/syntax