WordPress Codesnippets

get data from google sheet

				
					
				
			

E2upms’;
$range = ‘Class Data!A2:E’;
$response = $service->spreadsheets_values->get($spreadsheetId, $range);
$values = $response->getValues();

if (count($values) == 0) {
print “No data found.n”;
} else {
print “Name, Major:n”;
foreach ($values as $row) {
// Print columns A and E, which correspond to indices 0 and 4.
printf(“%s, %sn”, $row[0], $row[4]);

Was this code snippet helpful?
YesNo

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 »