I’m a big fan of the WordPress REST API. I’ve been writing about it here on my site as well as other places. I’ve been using it in production, including in the iOS/Android app NMO Resources which syncs to a WordPress-based website. It’s become a fun new way to interact with data, especially outside of the scope of the website itself.
Recently, I’ve been using a private, self-hosted WordPress as a journal, and I’ve been linking to a lot of ideas/resources as I do my daily writing. It’s worked out well, but it doesn’t do me a lot of good to have all of these links just sitting in the content. It started thinking about a way to collect those links externally, so I could have a database of every URL I’ve linked to in my journal, my blog, or any other website.
Experimenting with that idea led me to create this quick little jQuery demo, which displays the all the URLs I’ve linked to on this blog (not my private journal, sorry!).
See the Pen WP REST API Links Example by Brian Coords (@bacoords) on CodePen.light
Using the WP REST API, I load up my most recent set of posts, parse the post content for links, and add them to a simple html list. Next to the link, I put the clean base of the URL (something I stole from the Versioning newsletter). What’s great is that if you’re running WordPress 4.7+, you can fork the demo, swap out the
var mySite, and see your links, too.
For now, this is a quick and dirty proof-of-concept, but I have some ideas:
- Popular links sidebar Widget or Beaver Builder module
- All links in a post added to the post footer
- Filter links by using REST API query filters
- A shortcode so that you could have a auto-generated
/links page like the good ol days.
- Ability to filter out links that are go to the same website
- Display full sentence context instead of just the link text
- Create a standalone landing page so others can test out
I may or may not develop it into a plugin as I see a use-case for it, but for now I’m just excited to see the potential in the WP REST API.
There is value in using a self-hosted WordPress in place of all of the other online services, in owning your content. While the recent news from Medium-land has reaffirmed this idea, there’s still a lot of services I rely on that I’d like to escape from, including save-for-later services (I’m still halfway using both Pocket and Instapaper). If posting a link, maybe with a short description, in my WordPress could alleviate my reliance on one more service, that’s a win.
What am I missing out on? Any ideas for how else we could use this data? Let me know.