How one WordPress plugin can replace many | Boagworld - Web & Digital Advice

Web & Digital Advice

Digital and web advice from Headscape and the addled brain of Paul Boag... tell me more

Paul Boag Posted by: Paul Boag On Friday, 22nd July, 2011

How one WordPress plugin can replace many

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.

Reviews:
The estimated time to read this article is 5 minutes

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.

More Fields

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.

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.

Image of the tweet box on the new boagworld.com website

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.

The twitter box in the edit post page of WordPress

Then all I needed to do was call that field from within my template.


<script type="text/javascript">// <![CDATA[

twttr.anywhere(onAnywhereLoad);
function onAnywhereLoad(twitter) {
twitter("#tweetbox").tweetBox({
label: 'Twitter box',
defaultContent: "<?php
if (get_meta('tweetText') == '')
echo "Found this great post on @boagworld";
else
meta('tweetText'); ?> - <?php echo wp_get_shortlink(); ?> ",
height: 50,
width: 480,
});
};
// ]]></script>

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.

Featured post

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 featured post interface within WordPress post pages

The code for identifying featured posts is a simple modified WordPress loop.


 'featured', 'meta_value' => 1, 'posts_per_page' => 1, 'post_type' => array('post','episodes') ) ); ?>

Finally, I also realised I could use More Fields to solve my biggest problem, custom post designs.

Custom Design

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.

Custom CSS field in WordPress admin interface.

Other alternatives

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.

Become a web expert with our newsletter

Receive invaluable advice every three weeks and get two free video presentations for subscribing. You can unsubscribe in one click.

Blog Updates

You can follow all my posts by subscribing to my RSS feed or signing up to my email newsletter above.

Podcast Updates

Subscribe to the podcast via itunes or RSS. You can also subscribe to my quick tips via itunes and RSS too.

Social Updates

I am completely addicted to Twitter so try following me there. I also have a Facebook page which contains considerably less waffle.

Comments

Boagworld is a community, not just the voice of one blogger. You've read the post, now its time to get involved.