10up / simple-page-ordering

Order your pages and other hierarchical post types with simple drag and drop right from the standard page list.
https://wordpress.org/plugins/simple-page-ordering/
GNU General Public License v2.0
141 stars 22 forks source link

Update get_walked_pages to support custom post types Closes #200 #203

Closed zachgibb closed 1 month ago

zachgibb commented 1 month ago

Description of the Change

When reordering a custom post type, this get_walked_pages call fails with an undefined array key error on line 433.

Screenshot 2024-05-09 at 10 10 17 AM

Digging into it more, we can see that the get_walked_pages call is outputting only the top_level_pages for the page post type.

Screenshot 2024-05-09 at 10 16 21 AM

This is due to the get_pages call on line 200 (https://github.com/10up/simple-page-ordering/blob/develop/class-simple-page-ordering.php#L200) defaulting to post_type => 'page'.

If we tweak this to pass in the post_type of the post we're working with, in the same way we do with is_post_type_sortable, this issue will be resolved.

Screenshot 2024-05-09 at 10 22 48 AM

Closes #200

How to test the Change

Changelog Entry

Fixed error in call to get_walked_pages for custom post types

Credits

Props @zachgibb

Checklist: