Posted By

briteweb on 12/10/11


Tagged

edit action wordpress quick hook quickeditcustombox


Versions (?)

Fix duplicate fields with quick_edit_custom_box hook in Wordpress


 / Published in: PHP
 

Adding custom fields to the quick edit panel in Wordpress is easy using built-in hooks. However, the hook to add fields seems to be called multiple times, adding duplicate fields to the quick edit panel. Adding this code to the top of the function being called by quickeditcustom_box checks if the action has already been called and prevents it from being called again.

More info here

  1. global $post;
  2.  
  3. //if post is a custom post type and only during the first execution of the action quick_edit_custom_box
  4. if ( $post->post_type != 'post' || did_action( 'quick_edit_custom_box' ) !== 1 ) return;

Report this snippet  

You need to login to post a comment.