When developing in WordPress the number of plugins can quickly escalate out of control. Fortunately there are one or two plugins that make others unnecessary.
It was Ryan Taylor who first pointed out my problem (one of them at least). I’m obsession with WordPress Plugins.
Whenever I get stuck with a problem on WordPress, I turn to plugins as the answer. However, the more plugins you add the more likely one will be badly coded, not updated or clash with another. In short, too many plugins is far from ideal.
As I have worked on the new boagworld.com website I came up against three little things that (with my limited experience) I didn’t immediately know how to code in PHP. Previously I would have looked for three plugins to solve these problems. Instead, I discovered one super flexible plugin that solved all three and a lot more besides.
The plugin in question is More Fields and I would highly recommend it.
Essentially what the plugin does is put a nice UI over the top of custom fields. However, probably the best way to explain its benefits is to show the three places I am using it on the upcoming boagworld.com website. These three areas are…
- Recommended tweets
- Featured Posts
- Custom Design
Let’s start with recommended tweets.
While wireframing I came up with the idea of putting a tweet box at the bottom of each post to allow people to quickly tweet their thoughts on the post.
My problem was that a blank box with the article URL wasn’t very inspiring. Although I could have filled it with a generic tweet like ‘Check out this great article’ it would be nice to have a custom message on a per post basis. That way if I added something tweet-able into a post I could pre-populate the twitter box with it.
I could have used a custom field for this but bearing in mind my predisposition towards throwing a plugin at the problem I decided to go looking for one. That was when I discovered More Fields.
This allowed me to add a nicely formatted UI element into the edit page that allowed me to enter my custom twitter message.
Then all I needed to do was call that field from within my template.
The above code uses Twitter Anywhere to call the box but pre-populates it with my custom message if one exists using meta(‘tweetText’). If it does not exist it fills the box with a generic message instead.
Once I had set up More Fields it occurred to me it would allow me to get rid of a plugin I had previously installed; featured posts.
You can also use More Fields to feature a specific post. I am using it to display features both on my homepage and on my category listing pages.
All you need to do is add a check box field and then return posts with the box checked in your template.
The code for identifying featured posts is a simple modified WordPress loop.
<code> <?php query_posts( array( 'meta_key' => 'featured', 'meta_value' => 1, 'posts_per_page' => 1, 'post_type' => array('post','episodes') ) ); ?> </code>
Finally, I also realised I could use More Fields to solve my biggest problem, custom post designs.
Once in a while I want to publish a post with a slightly different design. The design is unique to the post and so a custom post type isn’t really the right choice. What I really need is the ability to add CSS on a per post basis.
One way of doing this would be using the unique post id attached to the body tag. The problem with this is that your CSS file would become bloated with stylings that most user may never need (as they aren’t visiting the associated pages).
The answer was to allow me to post inline styles associated with the specific post. Fortunately More Fields made that easy. I simply added a custom text box into the post and then called that from within my template. Job done.
My wonderful and all-knowing twitter follows have told me about an alternative which is possibly even better. That is Magic Fields.
I have had a look at Magic Fields and it is impressive. It looks both more flexible and more powerful than More Fields. However, as with anything, with this extra power comes complexity.
In my case and I suspect many others, the functionality provided by More Fields is probably be more than enough. I am a simple man and so generally prefer the simplest solution that does the job!
That said, if you have worked with either or both plugins I would love to hear your comments below.