Comment form for WordPress.
A lot of code is loaded because of one single functionality. This is not good at all.
Is there an alternative to the native jQuery?
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.6.0/jquery.min.js"></script>
<form id="contactForm1" action="https://exsample.com/wp-json/wp/v2/comments/" method="post">
Name : <input name="author_name" value=""> <br>
E-mail : <input name="author_email" value=""> <br>
ID post: <select name="post" class="form-control pronamic-wp-posts-example"></select> <br>
Comment : <textarea name="content" id="" cols="30" rows="10"></textarea>
<button>Send</button>
</form>
<link rel='stylesheet' href='https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.0.0/css/bootstrap.css'>
<link rel='stylesheet' href='https://cdnjs.cloudflare.com/ajax/libs/select2/4.0.6-rc.1/css/select2.css'>
<script src='https://cdnjs.cloudflare.com/ajax/libs/select2/4.0.6-rc.1/js/select2.full.js'></script>
<script>
jQuery( document ).ready( function( $ ) {
$( '.pronamic-wp-posts-example' ).select2( {
allowClear: true,
minimumInputLength: 3,
ajax: {
url: 'https://exsample.com/wp-json/wp/v2/posts',
dataType: 'json',
data: function ( params ) {
return {
search: params.term
};
},
processResults: function( data ) {
return {
results: jQuery.map( data, function( obj ) {
return { id: obj.id, text: obj.title.rendered };
} )
}
}
}
} );
} );
</script>
Sorry for my English.