问题
I am trying to make a wordpress theme that has a feature where you can add/remove/rearrange rows in a table. Ideally I would want it to be a drag and drop action. The output needs to simply be a table with several header rows, followed by content rows. This is for an actor's website, so it would be for a resume page. So FILM>credits THEATRE>credits
This is what the end product should look like:
Pretty much I'm just trying to make it as easy as possible for a user to change his/her resume. Right now I'm using add-row-below" buttons in the tinyMCE, but that can get kind of confusion for non tech people.
Ideally I would be able to add this to a certain page inside of wordpress, but putting it in a settings tab for the theme would work as well. Any thoughts, ideas, answers would be most appreciative!
回答1:
For an end user, I'd suggest a Custom Fields plugin solution like in this other Answer (using Custom Content Type Manager or Advanced Custom Fields).
Programmatically, a Repeatable Field is the way to go.
This helper library may be of interest, Admin Page Class:
Works with plugins as well as themes
Easily brand-able (via hooks).
Import Export features.
Available fields are:
[...]
Sortable Drag & Drop
Repeater Field which can be set as sortable
OOP Code all the way (which means easy to extend and modify).
A Gist example of Meta Box with a Sortable Repeatable Field --fork
And a full example here at SO: Adding custom image fields and other fields at the same time.
来源:https://stackoverflow.com/questions/13292764/how-to-add-table-rearranging-to-wordpress-backend