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%' });