Skip to content

Instantly share code, notes, and snippets.

@joehoyle
Created October 13, 2015 19:47
Show Gist options
  • Star 8 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save joehoyle/c5b48707aeee116bc6a4 to your computer and use it in GitHub Desktop.
Save joehoyle/c5b48707aeee116bc6a4 to your computer and use it in GitHub Desktop.
this.$el.find( '.taxonomy-terms' ).select2({
multiple: true,
ajax: {
url: WP_API_Settings.root + 'wp/v2/terms/' + this.options.taxonomy.slug,
data: function( term, page ) {
return {
search: term,
page: page,
_envelope: true
}
},
results: function( data, page ) {
return {
results: data.body.map( function( term ) {
return { text: term.name, id: term.id };
} ),
more: data.headers['X-WP-TotalPages'] > page
}
}
},
width: '100%'
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment