Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • [email protected]
    Participant

    Can I use the REST API to modify a shortcode? Seems not to work… (I changed the show_in_rest to true already). Here’s a snippet of my python code.

    def update_wordpress_post(html_content):
        wordpress_url = f"{rest_api_endpoint}{post_id}"  # REST API URL for creating a post
        username = "username"
        password = "application_pwd"
    
        # Prepare the data for the request
        data = {
            "title": "name_of_the_shortcode",  # Set the title of the post
            "content": html_content,  # The generated HTML content
            "status": "publish"  # Publish the post immediately
        }
    
        # Make the POST request to the WordPress API
        response = requests.post(
            wordpress_url,
            json=data,
            auth=HTTPBasicAuth(username, password)  # Basic Auth using username and app password
        )

    Hi Alex,

    Thanks for using Shortcoder. Shortcoder uses “custom post types”. So if you are able to edit a custom post type usign your script, then it should work for shortcoder too.

    I haven’t tried editing any custom post type with REST API.
    Can you please let me know what happens in your case?

    Thanks,
    Aakash

    [email protected]
    Participant

    Hey Aakash! Thanks for the quick reply!

    To be honest, I moved on from this problem. I hacked around it by writing the html code directly into the post_content of the shortcode in the database using SQL. Works fine for me, it’s a bit wonky but is stable enough.

    I think making the shortcodes editable by the REST API would be a really great feature.

    Hi Alex,

    Glad you figured it out.

    Shortcoder sets the content in the post_content field of post. So if you are using that already to modify the shortcode content, then there is no need to worry.

    Thanks,
    Aakash

    [email protected]
    Participant

    Yapp, thanks. Great job with shortcoder, btw. I guess this request can be closed then.

Viewing 5 posts - 1 through 5 (of 5 total)
  • You must be logged in to reply to this topic.

Subscribe to our Newsletter

Get updates on the WordPress plugins, tips and tricks to enhance your WordPress experience. No spam. View newsletter

By using this website, you agree to our Terms