WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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: http://www.bennettfeely.com/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.

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:

        $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!!

share|improve this question
Your ajax call can't work. Please take a look at the jQuery manual how to do it. – kaiser Oct 21 '12 at 21:41
I think it is likely that you are experiencing an infinite loop with wp_update_post(). What actions/hooks are you using to fire the code in update.php? – Ethan Hinson Nov 8 '12 at 3:18

hmmm.... I don't see a problem with your code. When I run into 500, it's usually due to permissions or htaccess mis-routing the request.

That said, some things to try: 1) in wp-config.php, set debug WP_DEBUG to true. This may offer a more descriptive error message.

2) Wordpress has good integration for AJAX. You can define a url to retrieve all ajax requests, and then handle the request from functions.php by adding an action. Check this for more info: http://codex.wordpress.org/AJAX_in_Plugins. I use the approach therein described quite often without incidence.

share|improve this answer
Thanks! I'm still getting a 500 "Failed to load resource" from the Chrome inspector. I set WP_DEBUG to true, but I'm not sure what to do/look for now...? – Bennett Oct 21 '12 at 23:06
debug should spit out info if there are more specific errors. If you want to link me to the site, I can take a closer look – Pizaul Oct 21 '12 at 23:23

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.