[Plugin: CMS Tree Page View] Bugfix -> insert
-
Hi!
Just a little bugfix. When inserting a page into the structure it always gets added in first place with menu_order=0. This breaks up the menu-ordering if there are other pages with menu_order=0 in the same place.
Old part of code (functions.php, ~ line 960)
if ( "inside" == $type ) { // post_node is moved inside ref_post_node // add ref_post_node as parent to post_node and set post_nodes menu_order to 0 // @todo: shouldn't menu order of existing items be changed? $post_to_save = array( "ID" => $post_node->ID, "menu_order" => 0, "post_parent" => $post_ref_node->ID ); wp_update_post( $post_to_save ); echo "did inside"; }New
if ( "inside" == $type ) { // post_node in first place, so order=0 // update menu_order of all pages with parent ref_node_post to keep order clean - only if there is an item with order 0 $min = $wpdb->get_results( $wpdb->prepare("SELECT MIN(menu_order) AS \"min\" FROM $wpdb->posts WHERE post_parent = %d", $post_ref_node->ID) ); if($min[0]->min==0) $wpdb->query( $wpdb->prepare( "UPDATE $wpdb->posts SET menu_order = menu_order+1 WHERE post_parent = %d", $post_ref_node->ID ) ); // post_node is moved inside ref_post_node // add ref_post_node as parent to post_node and set post_nodes menu_order to 0 $post_to_save = array( "ID" => $post_node->ID, "menu_order" => 0, "post_parent" => $post_ref_node->ID ); wp_update_post( $post_to_save ); echo "did inside"; }
The topic ‘[Plugin: CMS Tree Page View] Bugfix -> insert’ is closed to new replies.