WP REST API Custom Fields to Google Maps

Manuel, the young shrimp-picker, five years old, and a mountain of child-labor oyster shells behind him. He worked last year. Understands not a word of English. Dunbar, Lopez, Dukate Company. Location: Biloxi, Mississippi. (LOC) flickr photo by The Library of Congress shared with no copyright restriction (Flickr Commons) 1 I had a site we used for the Great VCU Bike Race course that’s been sitting around. I knew it had lat/lng data for lots of urban bicycle related posts. My goal was to get it into Google Maps via the REST API. Get Custom Field in JSON By default you won’t see custom field data in your JSON endpoints. There are some plugins to make that happen but I wanted to take a stab at doing it myself. Given the documentation, it was pretty trivial.2 The code below in a plugin or the function.php file would make the lat_long custom field show up in the post JSON. Using this URL, I can get the 30 most recent posts.3 Some Map Stuff Google wants lat/lng separate but it’s coming in as one item split by a comma. These little functions split it up nicely. In javascript, split breaks up a string by the defined element (comma in this case) and returns the pieces as an array. Since I’ll get two pieces […]

Custom Fitted WordPress

flickr photo shared by Internet Archive Book Images with no copyright restriction (Flickr Commons) I’ve been doing a whole lot of WordPress customization lately for really widely varying purposes/people. It has been a lot of fun and it’s an option that I’m not sure has been conveyed well to our faculty. Many times, faculty are looking for a process for students (or one another) that is semi-structured. The students have options but they need help remembering to do certain things (include at least one image, consider these three topics, add a link, etc.) or they need a bit of guidance to help create uniformity of some sort. If you’ve ever asked more than ten people to answer three questions in an email then you know that virtually all the humans fail to follow directions when given the chance.1 You’ll also see the width and depth of human imagination if you ask someone to fill in a text field answering a question you really thought was straight forward.2 There are also concerns about the complexity of WordPress that we can address through custom post types and custom user roles while still allowing for a good deal of flexibility within our established constraints. This interplay of custom fields, custom post types, and usually a custom theme to display the former is probably […]