There is nothing better than building a tool that can be used by many people. We were approached by New Futures to build a website a few months ago for their Smart Start campaign. One of their requirements was a tool to help their visitors look up their state representatives. We accomplished this by building a plugin for WordPress which New Futures has agreed to allow us to release to the public. Their investment in this plugin will now increase in value every time someone uses this plugin! Download the zip, check out the code on GitLab.
This plugin provides a set of shortcodes to build pages that look up US state representatives using Open State API data.
[legislator-lookup] shortcode creates an address input field that uses Google Places API to auto complete addresses.
[legislator-results] is used to display the results of the search.
Currently both shortcodes need to appear on the same page to function properly. Here’s what they look like in the editor:
legislator-lookup shortcode accepts two attributes:
placeholderwhich changes the default text in the address input.
submitValuewhich changes the default submit button text.
legislator-results shortcode accepts one attribute:
accordionwhich controls the representative result boxes appearing collapsed and opening one at a time. Default is
true, set to
legislator-results is an “enclosing” tag, meaning it can be wrapped around content in the editor. Anything the shortcode wraps will appear next to the results. This can be used to give users a script to follow or some context for what to do after they search.