Skip to content

Instantly share code, notes, and snippets.

View regiside's full-sized avatar

Reggie Lloyd-Jones regiside

View GitHub Profile
@regiside
regiside / taggable-taxonamy-input.php
Last active January 21, 2022 21:17
Allow Select2 taggable input on custom taxonomy metabox for Wordpress
<?php
// I wanted to be able to use Select2's tagging feature to add new terms to posts in wordpress. I slighlty modified the code from Misha Rudrastyh's excelent tutorial(link below). Comments are closed on that post so I figured I'd post this gist for anyone else wanting to do this. Here's the portion of code I modified:
// @https://rudrastyh.com/wordpress/select2-for-metaboxes-with-ajax.html
// Note: if you'd like to limit selection you can remove "multiple="multiple"" from the select box,
//or you can use Select2's "maximumSelectionLength" feature to limit to any number.
function rudr_display_select2_metabox( $post_object ) {
// do not forget about WP Nonces for security purposes