Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- Con POST -> Si crea un nuovo post, occorre definire i campi da modificare. URL: wp/v2/custom_post
- Con PUT -> Modifica il post, occorre definire i campi da modificare. URL: wp/v2/custom_post/id
- Con DELETE -> Cancella il post. URL: wp/v2/custom_post/id
- */
- $.ajax({
- method: 'POST',
- url: my_restapi_details.rest_url + 'wp/v2/course/45',
- data: {
- title: 'Giovanni truppi no',
- content: '[my_sample_shortcode]',
- type: 'post',
- status: 'publish',
- teachers: 'test',
- description: 'test2'
- },
- beforeSend: function ( xhr ) {
- xhr.setRequestHeader( 'X-WP-Nonce', my_restapi_details.nonce );
- },
- success : function( response ) {
- // Save the post ID in case you need it for something
- var myNewPostID = response.id;
- }
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement