# Show a cell from Google Sheets on WordPress using PHP

**URL:** <https://www.phphelp.com/t/show-a-cell-from-google-sheets-on-wordpress-using-php/35710>\
**Category:** Beginners - Learning PHP\
**Created:** [September 18, 2023, 4:00pm UTC](https://www.phphelp.com/t/show-a-cell-from-google-sheets-on-wordpress-using-php/35710 "2023-09-18T16:00:30Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![christa13](https://www.phphelp.com/letter_avatar_proxy/v4/letter/c/97f17d/32.png) [@christa13](https://www.phphelp.com/u/christa13)\
**Post date:** [September 18, 2023, 4:00pm UTC](https://www.phphelp.com/t/show-a-cell-from-google-sheets-on-wordpress-using-php/35710/1 "2023-09-18T16:00:30Z")

</div>

I found this code through a blog. I am attempting to return a single cell from Google Sheets. Forms will be completed on my WordPress website. The cell sums these forms. I want to return the sum from the Google Sheet. I have followed every step (correctly, I think!). It does not work. Short code just shows up on the website. It does not actually return the value in the single cell in Google Sheets. Can someone look at this and tell me what might not be working? Thanks!

```auto
function sheet_value_shortcode($atts) {
		$API = 'AIzaSyClwl_TDt4HzBXuGhgiYqmrAEyDZnPGmzE';
		$google_spreadsheet_ID = '1lbaeLarSa41rL-4dLin6I4oj5_X8SXzxlDsGyrnhJqw';
		$api_key = esc_attr( $API);

		$location = $atts['location'];

		$get_cell = new WP_Http();
		$cell_url = "https://sheets.googleapis.com/v4/spreadsheets/$google_spreadsheet_ID/values/$location?&key=$api_key";	
		$cell_response = $get_cell -> get( $cell_url);
		$json_body = json_decode($cell_response['body'],true);	
		$cell_value = $json_body['values'][0][0];
		return $cell_value;
}
add_shortcode('get_sheet_value', 'sheet_value_shortcode');

```

---

<div class="post-metadata">

**Author:** ![christa13](https://www.phphelp.com/letter_avatar_proxy/v4/letter/c/97f17d/32.png) [@christa13](https://www.phphelp.com/u/christa13)\
**Post date:** [September 18, 2023, 4:01pm UTC](https://www.phphelp.com/t/show-a-cell-from-google-sheets-on-wordpress-using-php/35710/2 "2023-09-18T16:01:16Z")

</div>

Here is where I found the code:

> **[How to Display a Single Cell in Google Sheets in WordPress](https://www.wp-tweaks.com/display-a-single-cell-from-google-sheets-wordpress/)**
>
> Here's how to easily display a single cell from Google Sheets in WordPress, so that your data is always the most recent. No plugins!
