Timeline for creating shortcode to pull json array
Current License: CC BY-SA 3.0
6 events
when toggle format | what | by | license | comment | |
---|---|---|---|---|---|
Aug 24, 2015 at 21:25 | comment | added | mpellas | If i could throw this out there...This is my current attempt: add_shortcode('aggrenda', 'requestAggrendaEvents'); function requestAggrendaEvents() { $url = 'aggrenda.com/mpellas/michael-pellas/events.json'; $response = wp_remote_get( esc_url_raw( $url ) ); /* Will result in $api_response being an array of data, parsed from the JSON response of the API listed above */ $api_response = json_decode( wp_remote_retrieve_body( $response ), true ); } | |
Aug 24, 2015 at 20:16 | comment | added | mpellas | I appreciate that! I'm really trying to get through this with one project that I'm building for a specific purpose. I'm getting the hand of PHP...but it's driving me crazy that I can't translate it over to Wordpress. It'll come in time :) | |
Aug 24, 2015 at 20:08 | comment | added | Rarst | I think I will let you build it out some more rather than dump bunch of stuff on your head. :) Processing of stuff doesn't have to be in the post content / shortcode and probably shouldn't, but if that's fastest for you to make sense of it for starters then just do that. | |
Aug 24, 2015 at 19:59 | comment | added | mpellas | Thanks for the answer. For my current skillset, I wasn't sure if add_shortcode or wp_insert_post would be more appropriate. I found wp_remote_retrieve_body today but haven't used it. Would you not use that in a shortcode? | |
Aug 24, 2015 at 19:52 | vote | accept | mpellas | ||
Aug 24, 2015 at 19:47 | history | answered | Rarst | CC BY-SA 3.0 |