Use Drag & Drop Functionality from WordPress Admin Area in the Frontend?

I'm building a membership site with a little pseudo-CMS on the frontend that allows users to post music-related items.

For this, I would like to give users the ability to order the items by using a drag-and-drop functionality like the one that exists in the admin area.

I created various custom post types (Band, Artist, Record) and would like the user to be able to order these into each other, i.e. a record should be associated with an artist and displayed under it and the hierarchies should change in the background as stuff is dropped around.

I already built the functionality based on a dropdown menu, but would like to to make it easier to use by allowing drag drop.

It surely would make more sense to use WordPress' native functionality than to custom-code the function, but I wasn't able to find any information on it after two hours of googling which is why I decided to ask the community here.

Topic drag-drop admin-menu hierarchical Wordpress

Category Web


You can enqueue those scripts in your theme to use it. It's all part of jQuery ui;

https://developer.wordpress.org/reference/functions/wp_enqueue_script/

wp_enqueue_script(
 array(
   'jquery-ui-core',
   'jquery-ui-sortable'
 )
)

https://jqueryui.com/sortable/

About

Geeks Mental is a community that publishes articles and tutorials about Web, Android, Data Science, new techniques and Linux security.