--- title: "Add a drag-to-rank form to WordPress: a shortcode you can build today" description: A WordPress drag-to-rank form in a single shortcode. Visitors sort items by dragging them into order, then submit the ranked list to your inbox. source: https://steem.dev/blog/wordpress-drag-rank-form-shortcode published: 2026-10-25 updated: 2026-10-25 site: Steem — AI WordPress plugin generator --- # Add a drag-to-rank form to WordPress: a shortcode you can build today Most WordPress forms are built around text boxes, checkboxes, and dropdowns. They work well for collecting names and messages. They do not have a native way to let visitors put a list of options into their preferred order, which is what you need when the question is 'rank these from most important to least' rather than 'pick one.' The usual workaround is to label each option with a numbered dropdown: Rate this feature 1 through 5. It is awkward to fill in, and the results require work to interpret. A drag-to-rank form asks the same question in a way that is intuitive and delivers the answer as a readable ordered list. A small shortcode handles this without a full form plugin. You add [drag_rank] to any post or page, supply a list of items, and visitors see a vertical list they can reorder by dragging. When they submit, the ranked list arrives in your inbox along with their name and email. ## What one build covers - Shortcode [drag_rank] with items, to, subject, and button attributes - HTML5 Drag and Drop sorting with no JavaScript library or external dependency - Name and email collection from the submitter - Email delivery of the ranked list via wp_mail to a configurable address - Confirmation message displayed on the same page after submission ## What it does not cover - Database storage of results, one email per submission only - Mobile touch-based dragging, HTML5 drag events do not fire on touchscreens - Multiple ranking questions combined into a single form submission - Aggregated results view or reporting dashboard in wp-admin - Integration with Gravity Forms, WPForms, or Contact Form 7 ## The prompt ```text Build a WordPress plugin called Drag to Rank Form. Plugin Name: Drag to Rank Form. Description: A [drag_rank] shortcode that lets visitors rank a list of items by dragging them into order and emails the result. Single PHP file. No external CSS or JavaScript libraries. Register a shortcode [drag_rank] with these attributes: items (comma-separated list, required), to (email address string, defaults to get_option('admin_email')), subject (string, defaults to 'Ranking submission'), button (string, defaults to 'Submit your ranking'). At the top of the shortcode function, generate a unique ID with uniqid('drr_') to namespace the list and hidden field so multiple shortcodes on the same page do not conflict. If the current URL contains the query parameter drag_rank_success=1, output a
with the text 'Thank you. Your ranking has been submitted.' and return early, showing no form. Otherwise, render a
. Include: a hidden input name='action' value='drag_rank_submit'; wp_nonce_field('drag_rank_submit','drag_rank_nonce'); a hidden input name='drag_rank_to' value of the escaped to attribute; a hidden input name='drag_rank_redirect' value of get_permalink() escaped; a hidden input name='drag_rank_order' with an id of the unique id plus '_order'. Render a name field and an email field, each required, with max-width 400px and display block. Render a