WP Rest API Tips

Cowboy Jason Stanley performing a riding trick at the Round-Up, Pendleton, Oregon flickr photo by UW Digital Collections shared with no copyright restriction (Flickr Commons) I’ve been doing quite a bit more with the WordPress Rest API lately. There’s plenty of documentation and tutorials out there but most of it still feels a bit scattered to me so I’m going to stick a few of the basics here and add a few things that have come up repeatedly that aren’t quite as basic. There’s an attempt here to move upwards in complexity with the examples but to keep them as clean as possible. This will deal entirely with getting the data. I haven’t done much with using the API to write or modify data. Get the Info There are many ways to get data depending on your library of choice or if you’re using vanilla JS. I’ve played with fetch and Axios on the lighter side and jQuery, Vue, and Angular (v1) on the heavier/more involved side of things. I’ll use jQuery in this version because it’s fairly popular but here’s a Vue example. The example below does a basic jQuery ajax call for the JSON associated with blog information. See the Pen simple jquery get of WP JSON for the site by Tom (@twwoodward) on CodePen. The URL Structure/Accessing […]

Set Default Gravity Forms From Email

On rampages we only have the ability to send out emails from rampages.us addresses. This caused a bit of confusion for me when our Gravity Forms email notifications stopped working.1 It seems like Gravity Forms now defaults to send emails from the form admin’s email address. In our case, that’s a vcu.edu domain . . . . which causes the emails to fail. You can see that when you go to Settings>Notifications for a form. The From Email now says {admin_email}. We have Gravity Forms network activated on rampages which means it’s live on all 17,000+ sites. Granted, I have no real idea how many people use it but I didn’t relish the thought of how many questions this might cause. Luckily, Gravity Forms has a way to take care of this and I was able to write a tiny, little, itsy, bitsy plugin to set the from email for all our sites. Problem solved. 1 Tim, from the ever-reliable Reclaim Hosting guided me back to sanity after I tried to make this much harder than it needed to be.

Gravity Forms + FacetWP = Gravatar People

Having just finished presenting1 at NMC. I said we all need to document more, to show examples and explain what we did. Making the notes for the presentation last night and being able to use the blog posts I’d already written really showed me the value of reflecting on little things in an ongoing way. It’s amazing how much stuff I do that I completely forget even happened. So this is how you’d make a gravatar people browser based on information submitted via a Gravity Form.2 This image above shows the basic setup for the Gravity Form. Form fields essentially get combined with some HTML in the post body field. It’s pretty simple but it might help someone. This is the basic setup in FacetWP that generates the query and the display code. There are two elements. Element one is the query which tells which pieces of content you want. The second part is the display which shows the content that you’ve retrieved in whatever way you define. The text version for the FacetWP template is below. There’s also a dab of CSS. 1 Or at least talking in a room with humans in it. It was not of enough quality to justify the term presentation. I need to figure out why that felt so bad. 2 Could also do […]


Rampages Growth Plotted

As part of the gen ed seminar I pulled the rampages.us user signup data for Kristina Anthony. It was just a straight export from the wp_users table and stripped of everything but the date. She pulled it into Excel and used a pivot table to make it manageable. Which is awesome. So I pulled it down and pushed it back up into Google Docs so that I could embed the chart in this post. It makes me feel better to look at the growth over what amounts to around a year of actual use. I tend to focus on places for improvement (and there are many) but it’s worth looking at what ALT Lab has managed to achieve in a fairly short period of time.1 The July to February jump of about 6000 users is pretty insane. I have every expectation that we’ll add another 6000 or so users next year. Things will certainly only get more interesting. This has been done without huge student training initiatives. For the most part faculty members are able to support their own students. We have some of that filter up and we deal with some troubleshooting online but there’s no dedicated person(s) to support WordPress issues or train students. That’s a testament to WordPress. 1 In the higher ed dimension a year is […]

Geo Tagging WordPress

First, go try it out if you want. Submit something. It’ll help it make more sense. I thought this would be a lot easier than I made it. I tried lots of paths and considered spending various amounts of money to make this easier. Please benefit (probably) from my wandering. I try to link in where I learned different things and, more importantly, I tried to emphasize vocabulary that might be useful to you. My goal1 was to- have a Google2 Map interface that auto-located the device allow the user to drag the marker to adjust the location plot the resulting WordPress posts on a map To make this work you do need a Google Maps API3 key and on the WordPress side you’ll need the Gravity Forms (Costs money but worth it) and Geo Mashup (free) plugins. Gravity Forms will let you create posts via a form and provision form elements via URL parameters. Geo Mashup is the friendliest way I found to display posts on a Google Map based on lat/long parameters associated with the post. Auto Locate I went to a few different places for this but ended up finding/using the handy example posted in the Google Maps API documentation. It took me a while to get there- “geolocation” is the key term. Add it to your […]

Troubleshooting Patterns

I got an email from a professor who was using Gravity Forms to allow students to create blog posts. The problem was that when they submitted posts via the form the category ended up being the default category no matter what was selected. Here’s a few of the things I did trying to figure out what was going on. It’s just a matter of isolating variables but occasionally it’s helpful to see how people work through this sort of thing. First, I googled it but that well was dry.1 I made sure the Gravity Forms category selection worked on other sites on the same installation. It did. That let me know it was at least blog dependent. There were only two other plugins active. They were both turned on and off with no change. That meant no plugin conflicts. On the input side, I tried selecting multiple categories. No dice. I tried changing the default category. It change the default category but didn’t fix the issue. I couldn’t think of any more input based variables to mess with so I moved a bit deeper into things. On the form side, I tried changing the category selection options. I tried using checkboxes, multiple select, all categories, select categories etc. None of that made any difference. I copied the form to see […]

The Tao of Posts

I’ve been having quite a few conversations around student portfolios eportfolios online representations of their learning over time. These conversations have mostly centered on using WordPress and, almost inevitably, the first instinct is to create a series of pages that are aligned to either courses or assignments. Those pages usually contain a number of different pieces of content. That structure makes the most sense to people who are used to building websites in the Dreamweaver/static paradigm. I don’t think this is the right path in most cases. It’s easy in the short term but starts to limit you (absent lots of work) in the long run. Strange that I don't really know what a web page is anymore. Individual tweet? Blog post? Flickr image? #vcuols — Tom Woodward (@twoodwar) May 14, 2014 At the heart of this is the issue that “page” is hard to define. In the broadest sense anything I can address with a URL is a webpage. That’s a big bucket. WordPress makes things more complex by including a way to create pieces of content called “pages.” Pages are usually contrasted to posts. I usually described1 the page/post difference was that posts were pieces of content that flowed with the timeline (more ephemeral but archived) and pages were pieces of content you wanted to be more permanent/static. […]

Hollywood Cemetery – Preliminary Thoughts

I’m pretty excited about a new project we’ll be working on this year. We’re going to look at a local historically significant, but still active, cemetery through a variety of disciplinary lenses. Hollywood Cemetery is the permanent home of two presidents of the USA (James Monroe and John Tyler) and one president of the CSA as well as a variety of other interesting local people. Dr. Ryan Smith from VCU’s history department has already had students doing quite a bit of work with local cemeteries. Back Story also recently republished a podcast (Grave Matters) which mentions Hollywood cemetery quite a bit and is all kinds of good. Even the Girl Scouts have some great information on Hollywood Cemetery1. So that brings up the question- What can we do that hasn’t been done and how can we make this something really valuable to the community- both locally and at large? The Players and Their Lenses Looking through the lens of sociology, Dr. Susan Bodnar-Deren will be helping us think through work around mortality, social status etc. by analyzing the data from gravestones.2 Dr. Bernard Means will be bringing an archaeological3 and 3D imaging background4 that he has honed in VCU’s Virtual Curation Lab. Dr. Ryan Smith will round out our professorial group with his focus on history. I will be playing […]

Field Botany WordPress Site Breakdown

The Field Botany class is underway and the vegetation is rolling in despite floods and hail. There are 20 student participating on 20 different blogs. Right now we have almost 700 posts in the mother blog. Amazing to see all this great work and to be able to keep it instead of having it stuck in paper notebooks which only a few people ever saw and no one in the public could use. This early days for the site but in the end the intrepid biology duo of Jill Reid and Dianne Jennings will worked with their students to create a site that local residents can use to identify plants in our James River Park System. The nice thing about this setup is it can be used as is or modified to support a variety of other scenarios pretty readily. It has already inspired a sister project that will be documenting mortality and local cemeteries with Susan Bodnar-Deren (who just finished the first round of theOnline Course Development Initiative). Plugins Used On The Mother Blog/Set Up NS Cloner – Site Copier – This was handy for setup. In this case we wanted student sites to have the categories, pages, themes, and plugins already activated. This plugin let me do that easily from a blank template site. The free version doesn’t […]

Biology Field Journal – Gravity Forms + Google Maps for WordPress

Turns out this won’t work for what I originally planned but the pattern is sound. You can see the form here and examples of the form submissions here. You’ll need Gravity Forms (pay but well worth it) and Google Maps for WordPress but the idea should work for all kinds things. The original goal was to have structured posts from students and the ability to associate those posts with a point on Google Maps. After turning on the plugins, all the work is done in Gravity Forms. Initially, make a text entry fields for latitude and separate text field for longitude. Add all the other fields you want in the mix. In this case we added some categories to do with the environment, plant descriptions etc. Gravity Forms is fairly unique in that it has post elements for WP built in. I added the Post Body and Post Title fields at the bottom. Now we just need to create the content template that’ll mix our variables into the body of the post.   You’ll notice in the image above that when ¬†you mouse over an element it displays the Field ID – in this case 2. That’s important as to add this field you’ll need to reference both the title and the field ID like so {Latitude:2}. The image below […]