Design & Development

WP Plugin Business Address

Posted on

A client asked me the other day if there was a way to write his address once in the backend, and display it in various places throughout the site.

Quickly, my answer was “yes, of course”, after all we’re just creating some variables and echoing them. A few solutions came to mind, but I did a quick search for ideas on the best way to do this:

  • One post suggested editing the Theme Customizer and placing info like this there. Which would achieve the goal, but I didn’t like putting data like this in the Customizer.
  • We could use a widget? I really don’t like using widgets for too much, that’s an area of WP that just seems a bit disjointed to me, and have a hard time getting clients to use them.
  • I use ACF for many things, and their Theme Options seemed like a good approach, and ironically seemed more tempting than most of the core WP ideas.
  • Or use an already existing plugin.

So, I looked for a plugin.

There is a plugin for everything, so I assumed I’d find one for my needs, to simply write an address in the backend and display in the theme. I looked and saw some that were close, but either offered too much or were heavily styled, or just had a different goal in mind.

So, I wrote a plugin.

As mainly a theme developer, I took a stab at writing this plugin which seemed like it would be pretty straight forward.

When installed, it’s located under the ‘Settings’ menu in the admin, and offers fields for an address and telephone number. There are no style or scripts, it simply will echo the address where ever you’d like using the shortcode [business_address]. The items have span’s with classes wrapping them so it will initially disply inline-block, but the hooks are available for styling as you like.

ba-fields

Currently it’s available on GitHub. As I tweak it a bit more I’ll promote to v1 and submit it to the repository. Please feel free to check it out, use it, and offer any feedback.

Published under: WordPress
Tags: , ,
Previous Design and Development Love

Bare-bones html navigation menu

Next Design and Development Love

Remove all characters from a string for a clean phone number link

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.