wordpresselementor

How to post content to Elementor Pages using Wordpress API


With the below mentioned Wordpress API Call, the content gets posted to the page ID, but the changes doesn't appear on the Elementor Page.

Headers:
  - Authorization: Bearer YOUR_WP_API_KEY
Body:
  {
    "title": "New Title",
    "content": "New Content",
    "status": "publish"
  }

Postmaster API response shows that the content has been updated,

Any help/suggestion is highly appreciated.


Solution

  • You can use two different API endpoints. One for posts, and one for pages. Make sure you're using the right endpoint. So, if you use the right endpoint. There is a second thing to consider. Elementor is storing its editor data inside its own meta key _elementor_data we need to empty that. And then you will see your new content appear.

    For posts use [POST REQUEST]:
    [your-domain.name]/wp-json/wp/v2/posts/{postID}

    And for pages you can use [POST REQUEST]:
    [your-domain.name]/wp-json/wp/v2/pages/{postID}

    You don't have to specify your title and status, you can just post the content and the elementor meta key inside your JSON:

    {
        "content": "My new content yes!",
        "meta": {
            "_elementor_data": ""
        }
    }
    

    Also, for everyone:
    If you create a bearer token for your WordPress user, make sure to use your username as the username for your bearer token, not the 'App name' you gave while creating the bearer token. This can save you some headaches.