[wp-trac] [WordPress Trac] #15312: Bug with remove_meta_box bug with pageparentdiv when saving a page

WordPress Trac wp-trac at lists.automattic.com
Thu Nov 4 00:07:09 UTC 2010


#15312: Bug with remove_meta_box bug with pageparentdiv when saving a page
----------------------------+-----------------------------------------------
 Reporter:  maorb           |       Owner:                 
     Type:  defect (bug)    |      Status:  new            
 Priority:  normal          |   Milestone:  Awaiting Review
Component:  Administration  |     Version:  3.0.1          
 Severity:  normal          |    Keywords:  pages, meta_box
----------------------------+-----------------------------------------------

Comment(by maorb):

 Well, I've continued to check it, and found that indeed, when removing the
 meta_box of parent_div, the parent_id is not being sent in via submit, so
 the $_POST does not have a value for it, and it appears then to get value
 of 0.

 In order to fix this in my case, I wrote a small function to hook the
 save_post action and preserve the current post_parent id and write it
 directly to the database.
 Anyway, I think this issue should be fixed in the core.

 Here's my function I wrote for this:


 {{{
 function tc_persave_page_parent($post_id) {
         global $post, $wpdb;
         $q_upd = "UPDATE $wpdb->posts SET post_parent = $post->post_parent
 WHERE ID = $post->ID;";
         $res = $wpdb->get_results($q_upd);
 }

 add_action('save_post', 'tc_persave_page_parent' );
 }}}

-- 
Ticket URL: <http://core.trac.wordpress.org/ticket/15312#comment:1>
WordPress Trac <http://core.trac.wordpress.org/>
WordPress blogging software


More information about the wp-trac mailing list