Originally based on the code by Matthew Connerton on the Gravity Forms support site, I have modified his original code to also trim the zip code into the first 5 digits. Currently with Gravity Forms, there is no (easy) way to change the input fields to only accept 5 digits (or any other number) and/or change the submitted state selection to their USPS equivalents. If you're trying to use your data to generate mailing labels or anything similar, the way it is setup can be messy and/or problematic. Hence, the solution Mr. Connerton, and now myself, have developed. It is written as a plugin so all you have to do is download the file below, unzip it and put it in your WordPress plugins folder. It will then modify the submitted entry prior to it being saved to your database, and BAM! You're a happy camper. So what does this plugin do in short? -
- Trim submitted zip codes to 5 digits
- Convert full state names to their USPS state abbreviations
I chose this subject to write about for two reasons. One: I'm sure there are folks out there who will find this useful. And Two: I can never remember it myself so by writing about it here, I won't have to remember, I can just refer back to my own blog! Often, when using WordPress multisite as a content management system rather than a blog network, I have the need to use a blog slug in image paths, or when doing DB queries or whatever. There are lots of reasons, but here's how you get it > 1 I find the $GLOBALS variable to be really useful. If you'd like to see all the stuff you can get out of there, just drop this line in your theme somewhere (it's quite long, so best not to do it on a production site)- 1 Enjoy!
Kudos to Dimox for a great non-plugin WordPress function for creating breadcrumbs. For someone like me though, who is implementing a WordPress Mu site using "blogs" as content sections instead of the traditional community of blogs, I'd like to be able to have breadcrumbs that go more like this- Home (root uri) » Blog Home (blog uri) » normal breadcrumbs To accomplish this, I just made a few modifications to Dimox's code and with the power of WordPress, Shazam!, it was done. Here's the chunk of code I added/modified (note, this code goes in your themes' functions.php file): 1 And that's it, now just do everything else as Dimox suggests on his site. Enjoy!