Title: Adding menu_order to plugin
Last modified: August 22, 2016

---

# Adding menu_order to plugin

 *  [aspacecodyssey](https://wordpress.org/support/users/aspacecodyssey/)
 * (@aspacecodyssey)
 * [11 years, 8 months ago](https://wordpress.org/support/topic/adding-menu_order-to-plugin/)
 * I was scouring high and low to find a plugin that would allow me to use the built-
   in WordPress attachment pages to create a simple gallery. I could not find a 
   way to have the order things sort on the attachment pages (i.e. for previous_image_link
   and next_image_link) match they way the gallery sorts them. I came across this
   plugin and tried using it for that, but realized that attachments are not sorted
   by post_date, but rather by menu_order, which is a field that is uneditable by
   default.
 * I added that functionality by mimicing your code:
 *     ```
       if(!function_exists('mam_attachment_menu_order_edit')){
       	function mam_attachment_menu_order_edit($form_fields, $post) {
       	    $form_fields['post_menu_order']['label'] = __('Menu Order', 'mod-att-meta');
       	    $form_fields['post_menu_order']['value'] = $post->menu_order;
       	    $form_fields['post_menu_order']['helps'] = __('Modify the original menu order', 'mod-att-meta');
       	    return $form_fields;
       	}
   
       	add_filter( 'attachment_fields_to_edit', 'mam_attachment_menu_order_edit', 10, 2);
       }
   
       if(!function_exists('mam_attachment_menu_order_save')){
       	function mam_attachment_menu_order_save($post, $attachment) {
       		$post['menu_order'] = $attachment['post_menu_order'];
           	return $post;
       	}
       	add_filter( 'attachment_fields_to_save', 'mam_attachment_menu_order_save', 10, 2);
       }
       ```
   
 * [https://wordpress.org/plugins/modify-attachments-meta/](https://wordpress.org/plugins/modify-attachments-meta/)

Viewing 1 replies (of 1 total)

 *  Plugin Author [Vladimir Vassilev](https://wordpress.org/support/users/vloo/)
 * (@vloo)
 * [11 years, 3 months ago](https://wordpress.org/support/topic/adding-menu_order-to-plugin/#post-5176034)
 * Thanks a lot and sorry for the slow reaction!
 * Your code has been added to v.0.2 of the plugin.
 * Merry Christmas!

Viewing 1 replies (of 1 total)

The topic ‘Adding menu_order to plugin’ is closed to new replies.

 * ![](https://s.w.org/plugins/geopattern-icon/modify-attachments-meta_f4f4f4.svg)
 * [Modify Attachments Meta](https://wordpress.org/plugins/modify-attachments-meta/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/modify-attachments-meta/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/modify-attachments-meta/)
 * [Active Topics](https://wordpress.org/support/plugin/modify-attachments-meta/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/modify-attachments-meta/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/modify-attachments-meta/reviews/)

## Tags

 * [attachment](https://wordpress.org/support/topic-tag/attachment/)
 * [gallery](https://wordpress.org/support/topic-tag/gallery/)
 * [menu_order](https://wordpress.org/support/topic-tag/menu_order/)
 * [order](https://wordpress.org/support/topic-tag/order/)
 * [post_date](https://wordpress.org/support/topic-tag/post_date/)

 * 1 reply
 * 2 participants
 * Last reply from: [Vladimir Vassilev](https://wordpress.org/support/users/vloo/)
 * Last activity: [11 years, 3 months ago](https://wordpress.org/support/topic/adding-menu_order-to-plugin/#post-5176034)
 * Status: not resolved