1

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?

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

0

Your Answer

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.