WordPress Codesnippets

Upload file programmatically ajax


This code snippet contains two parts: JavaScript and PHP. The JavaScript part sets up a submission handler for a form with ID ‘formID’, using jQuery. When the form is submitted, an AJAX request is sent to the server, which triggers the PHP part of the code. The PHP part runs the ‘upload_file_callback’ function when the AJAX request is received, which handles the file upload process.

Was this code snippet helpful?

Leave a Reply

Your email address will not be published. Required fields are marked *

Programmatically save post

This code creates a WordPress post with the values of the ‘post_title’ and ‘post_content’ variables. It sets the post status to ‘publish’ and the author

Read More »

Create order programmatically

This code creates a new post in the WordPress database with post type ‘shop_order’, post title ‘Order #12345’, post status ‘wc-processing’, and ping status ‘closed’.

Read More »