Edit post via API ruins styles
-
Hello. I need to be able to update page media programmatically.
My current approach now is:
1) Update media items in the gallery (using endpoint https://developer.wordpress.com/docs/api/1.1/post/sites/%24site/media/%24media_ID/edit/)
2) Edit post by updating links to the up-to-date media items. On this step I fetch post from the endpoint https://developer.wordpress.com/docs/api/1.1/get/sites/%24site/posts/%24post_ID/, take a “content” field from the response, replace old links to new and post updated content to https://developer.wordpress.com/docs/api/1.1/post/sites/%24site/posts/%24post_ID/.The resulting page contains expected updated media items and unexpectedly smashed styles. I just took one page and created analogous items via custom html with inline styles (separate huge “thanks” to castrated list of available tags https://wordpress.com/support/code/#html-tags that do not contains scripts and styles) that saved their initial look.
Is there more straightforward approach to update post’s media that save styles and exclude manual html writing? If not, I request to introduce the corresponding feature that enables to update posts on the server side while updating a media via https://developer.wordpress.com/docs/api/1.1/post/sites/%24site/media/%24media_ID/edit/


The blog I need help with is: (visible only to logged in users)
-
Also, make the endpoints https://developer.wordpress.com/docs/api/1.1/get/sites/%24site/posts/%24post_ID/
https://developer.wordpress.com/docs/api/1.1/post/sites/%24site/posts/%24post_ID/
working in agreement. Because now getting “content” and simply posting it ruins styles. -
Hello!
Welcome to our free support forums for WordPress.com hosted sites. However, I’m sorry to inform you that we don’t provide support for the REST API here.
If you’re experiencing difficulties with those endpoints, I would suggest reaching out to our Developer Support team. They will be better equipped to assist you. You can contact them directly at this link: https://developer.wordpress.com/contact/
I hope this information is helpful to you!
-
- The topic ‘Edit post via API ruins styles’ is closed to new replies.