Support » Plugins » Figuring out how to use wp_update_post with ajax on frontend

  • I’ve been working hard trying to implement a frontend post editor “sidebar” on each post when I’m logged in.

    You can see what is going on here with a test post: After I get it working it will be restricted so only users with permission will be able to access the frontend editor, of course.

    I feel like I am getting close, but it still isn’t quite working and I’m not sure why…

    Here is the important part of the jQuery/Ajax I’m using currently:

    var post_data = $("#editor-post-form").serialize();
      type: 'POST',
      url: '/wp-content/....../update.php',
      data: post_data

    update.php consists of:

        if(isset($_POST['new_post']) == '1') {
            $post_id = $_POST['post_id'];
            $post_title = $_POST['post_title'];
            $post_content = $_POST['post_content'];    
            $the_post = array();
            $the_post['ID'] = $post_id;
            $the_post['post_title'] = $post_title;
            $the_post['post_content'] = $post_content;
            $post_id = wp_update_post($the_post);

    Using the awesome powers of the Chrome inspector, update.php is sending back an Error 500 (Internal Service Error). The form data appears to be sent correctly however.

    I’m guessing whatever problem I’m having is probably caused by some noobish mistake i’m making.

    Any help would be greatly appreciated. I would gladly give some more information or could try to clarify something if needed.

    Thank you!!

  • The topic ‘Figuring out how to use wp_update_post with ajax on frontend’ is closed to new replies.