Skip to content

Instantly share code, notes, and snippets.

@Shelob9
Created January 25, 2016 23:30
Show Gist options
  • Save Shelob9/152da768036c497e99d4 to your computer and use it in GitHub Desktop.
Save Shelob9/152da768036c497e99d4 to your computer and use it in GitHub Desktop.
Simple select2 for posts via WP API
$( '#search' ).select2( {
ajax: {
url: API.root + '/wp/v2/posts',
processResults: function( data, page ) {
console.log( data );
return {
//do something results
}
},
cache: false,
data: function ( params ) {
var query = {
search: params.term,
page: params.page
};
return query;
},
delay: 250,
}
} );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment