I'm trying to create a wordpress post with html code in content for images but I have a problem. For example my content looks like:

<p><img src="https://avatars3.githubusercontent.com/u/1?s=52&amp;v=4" style="width: 52px;"><br></p>

But in Wordpress editor this same code is with slashes so it doesn't display.

<p><img src=\"https://avatars3.githubusercontent.com/u/1?s=52&v=4\" style=\"width: 52px;\"><br></p>

Api call:

  $api_response = wp_remote_post( 'http://example.com/apiwp/wp-json/wp/v2/posts', array(
  'headers' => array(
    'Authorization' => 'Basic ' . base64_encode( 'admin:xxxx' )
  'body' => array(
    'title'   => $title,
    'content' => $text,
    'status' => 'publish',
    'format'   => 'standard'
) );

Is there any fix for this problem?

  • 1
    Can you also post your REST API call?? Jun 11, 2019 at 16:35
  • Edited my post.
    – M5_Crate
    Jun 11, 2019 at 16:39
  • 1
    My god. Just discovered that wysiwyg editor (summernote) is the problem with slashes..
    – M5_Crate
    Jun 11, 2019 at 16:50


Your Answer

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

Browse other questions tagged or ask your own question.