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
My favorite Denver SEO company Katz Web Services announced the release of their latest awesome plugin- WP Wunderground Plugin.
It's a well done, awesome plugin that allows you to use short codes to display the weather forecast in a widget or blog post.
For one of my clients however, we wanted the weather to be a part of the theme outside of a widget.
A small bit of code later, it's done. You can see the weather forecast for Roanoke, VA by clicking that link.
We installed the WP Wunderground Plugin and then added this bit of code to our theme file:
Now, an explanation of what you see.
Line 2 is a conditional statement checking to see if the plugin is currently active by checking to see if the plugin's class exists. It wouldn't exist if the plugin was active. You could also use the WordPress function
is_plugin_active() but I've run into a couple of instances where it returns an unknown function error.
Lines 3 & 6 are simply creating a container
«div» for styling purposes.
Lines 4 creates a new instance of the plugin class and Line 5 prints the result of the internal method
build_forecast(). The '24012' is the zip code I want the weather returned for and is also defined in the plugin settings.
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!
On September 8, 1966, Star Trek debuted in the United States on NBC. To honor the 44th anniversary, we have coded and released a novelty plugin for all of you Trekkies out there. The Stardate Plugin offers three core functionalities, the coolest of which is first:
- You know that publication date that shows up on your posts and pages? Change it from the traditional calendar format to a STARDATE. Oh yes.
- Use our fancy shortcode to insert the current stardate in a post or page wherever you like.
- Use our awesome function to integrate the stardate into your theme template anywhere you like.
Today's Stardate is 11703.25You can download the plugin from the WordPress repository here. More information can be found on the official plugin page- Stardate.
Apparently this little gem has been around since WordPress 2.5 (and as of this writing we're at 3.0.1) but I'm just now finding out about it. Good grief!
Gallery Shortcode TutorialSo you want a fancy WordPress gallery without having to install a gallery plugin? Yes, you can do that. Easy. It's as simple as the following steps:
- Start a new post (or edit an existing post)
- Using the "Add an image" icon next to "Upload/Insert" above the WYSIWYG editor, add the images you want to display as a gallery on your post. This is technically attaching images to the post.
- Wherever you want your thumbnail gallery of images to appear, add the shortcode-
Gallery Shortcode OptionsThe [gallery] shortcode also has other options available naturally if you want to customize your WordPress gallery. The basic options are pretty straight forward and include- columns, id, size.
The columns options, as you might imagine, sets the number of columns the gallery will have. The default is 3 if you don't specify a value. If you set columns to 0, row breaks will not be included in the output.
The id option allows you to pull images from a different post. So if your image gallery you want to display is attached to another post, rather than reupload all those images, just specify the post id of the original post and you're in business.
The size option allows you to choose what image size you want to use in your gallery. The default is "thumbnail" but you can also choose- medium, large and full. (Those sizes of course are the image sizes in your gallery that your image is resized to when you upload, except full of course, which is the original image size.)
Gallery Shortcode Advanced OptionsThere are some other advanced options as well that let you control thumbnail order, including or excluding particular images from the gallery and XHTML output. If you're interested in those, I recommend you check out the WordPress Codex.
Gallery Shortcode ExampleI uploaded a few photos to this post myself to show how this works. So without further ado, here's an example of the gallery shortcode.
[gallery columns="2"]. Hope you found this as interesting and useful as me! And all these photos are copyrighted. :)
I'm working on a new WordPress Mu site and am using Donncha's fantastic Sitewide Tags Plugin to pull all the posts from across my network of blogs onto one master blog for indexing features across my site. One thing I didn't realize however was that (at the moment) it only works on posts published AFTER you start using it. If you're like me you have 100s or 1000s or even more posts already in your network. I stumbled across some code the other day that will iterate through your blogs and pull the existing posts into the new tags blog. So Colas Nahaboo, whoever you are, thanks for this awesome bit of code: 1 The easy thing to do, is using the WPMU Power Tools plug-in, from Brian Freeman, run the above query exactly as it is across all blogs and within a few seconds all of your posts will be pulled in. Easy! Thanks to Andrea and Donncha for tips over the past few days, I always appreciate the help.
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!
I have a client who uses the Events Manager plugin by Davide Benini and Marcus Skyes to manage events on their site. Unfortunately, the plug-in doesn't let you display events by category (which is weird, otherwise, why have the categories?) but anyway, I wrote/hacked together a custom function and WordPress shortcode today to display the events by category. Now, I know there are going to be the naysayers who say "This code isn't very pretty". Yeah, well maybe not but it works. And if you can improve on it, DO! I'm totally open to it. For instance, the edit I did makes more than one query to the DB which isn't optimal. Okay, so without further ado, here it is. Open up the file in your events-manager/ folder called 'marcus-extras.php'. Around line 264 you'll find a function called dbem_get_category(). I added my custom function and shortcode right below it : 1 And then: 1 The shortcode is - [dbem_events_by_category] and you can just insert it into your post or page whereever you want it to go. By default it outputs ALL events under ALL categories but you could hack it up pretty easily to only display one category, etc. I may do that later if enough people ask for it but it's not what I needed so, didn't get done. :) Hope this helps some folks. Let me know if you have any questions!
So I have been honored with the distinction of "Cool Guy of the Day" from the ever-so-friendly and über-cool Brandy Eddings and cohorts. What do you need to win this award? My suggestion: an unusually strong grasp of obscure modern, 80s and 90s trivia and info. Knowing who this guy is helps too. Also, special thanks and props to Zule and the Keymaster (split personality is rampant in Dallas lately) for their vote as well.