Customizing the WordPress Post Quick Edit Form

This is Part Two on customizing the WordPress Post Quick Edit Form from my experience creating my Comment Redirector Plugin. Here we will focus on adding custom fields and populating them with javascript.  Part One where I described adding a custom column to the Post List display is here. As a reminder, all of the source code in this post is available on the WordPress Plugin Download Page.

The Comment Redirection Url is shown below. That’s the url inserted into the Comment Redirection Message HTML Template displayed at the bottom of each post instructing users where the post’s comments are located.

Adding the Field HTML

We add the Fieldset HTML using the quick_edit_custom_box filter function.

Populating our Custom Field on Page Load

Probably the most interesting aspect of customizing the Post Quick Edit Form is how we use javascript to populate the existing comment_redirection_url fields when the quick form is displayed via the a.editinline click() function. The javascript will use a delegate to post to ajax.php file which populates the #comment_redirection_url text field value. The php function generating the javascript shown below is wired up to the WordPress admin_head-edit.php filter.


There seems to be a lot going on here, but only because I designed it to allow developers to bypass the entire WordPress framework stack and pull a value directly out of MySQL if they wanted to.  Really, only 3 things are happening here. We

  1. Setup a MySQL Connection (either through wp-config.php or a custom config.php which bypasses the WordPress stack)
  2. Run a query and retrieve the post comment_redirection_url meta property from the database
  3. Echo it back to the Ajax post request

And that’s how we add a new Quick Edit Form field and populate existing field values. Like I said, all of the source code is available on the WordPress Plugin Download page if you need to dig into it more for your own plugin.

Until next time, Happy WordPress Plugin Coding!