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); }
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
- The topic ‘Adding menu_order to plugin’ is closed to new replies.