access JSON results from wordpress database with wpdb
-
I have JSON results from Google API added to to wp_options table. At this point I just need to echo the specific elements. Namely, the coordinates. The option_name I have is py_menu_item. One of the option_value element is coords. That is what represents the JSON results. The code below yields this response:
array(o){}
The code:
global $wpdb; $myrows = $wpdb->get_results("SELECT coords FROM $wpdb->wp_options"); $lat = $myrows->results[0]->geometry->location->lat; //latitude $long = $myrows->results[0]->geometry->location->lng; //longitude echo $lat; echo $long; var_dump($myrows);
I am using this Codex page as a guide: Class_Reference/wpdb
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
- The topic ‘access JSON results from wordpress database with wpdb’ is closed to new replies.