0

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.

2

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/

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.