WordPress Plugin Rundown: Some Very Useful Plugins

If you are new to WordPress, then you have undoubtedly been cast into the vast world of plugins, which sometimes seem to have no end. And finding one that perfectly fits your needs may seem to be an impossible task. Of course the plugin rating system helps a lot, but it’s far from perfect.

Consider yourself lucky, as I have a list of go-to-must-have plugins that I install in almost every WordPress instance I create. I’m sure it will be useful to someone.

  • Add Meta Tags — This plugin adds meta tags to your articles based on the categories, tags, featured image, and excerpt chosen. This becomes extremely useful for Search Engine Optimization, or SEO, as well as for various social plugins that import your articles for consumption via likes, +1’s, and shares. Definitely a must have plugin.
  • BackWPup –BackWPup allows you to export your database, as well as your files, to various services on a schedule. This ensures that if your server ever craps out and loses all your data, that you will a backup to get your server up and running again. Of course such backups can be done manually, and hopefully your host is doing some type of backup, but the automation and ease of use, along with the added peace of mind, is totally worth getting this plugin.
  • Blubrry PowerPress — Blubrry Powerpress is the best way to go if you are looking to release a podcast via your WordPress site. Setup is easy and you also have the option to integrate stats from the Blubrry website.
  • Disqus Comment System — Disqus is probably the most popular third-party commenting system on the web. This plugin provides easy setup and management of comments to your site. I find this is the number one way to reduce WordPress spam. Must have.
  • Google XML Sitemap — With Google Webmaster Tools, your XML sitemap will be used to more easily index your site and ultimately provide better SEO.
  • Scissors Continued — This is the best plugin that I’ve found for adding watermarks to only images of a particular size.
  • Simple Local Avatars — Profile avatar integration is probably one of the most disappointing parts of WordPress. Avatar functionality is built into the system, but there is by default no way to easily add an avatar to a particular user. This plugin takes care of that, as you can easily upload an image to a users profile and it will be seen throughout the site where applicable.
  • Ultimate Google Analytics — Google Analytics is hands down the website tracking tool of choice for the web. This plugin provide an easy way to get the analytics tracking code on all of your pages.
  • WP to Twitter — Although setup is not the most user friendly, WP to Twitter provides an easy way to auto-publish your articles to the highly popular micro-blogging platform.

Hope these help! What are your must have WordPress plugins?

WordPress 101: Adding a (YouTube) Meta Box to Page/Post Editing

The current version of WordPress (WordPress 3.3.1) allows for a theme creator to implement a ‘Featured Image’ meta box on the page/post editor for use in a custom theme. This can easily be added by just adding a single line of code to the themes setup function.

But what if you want to add more meta boxes to your page/post editor. While not as easy as the one line above, it may be easier than you think.

A quick goggle search for “wordpress custom meta box” yields the following result.

http://codex.wordpress.org/Function_Reference/add_meta_box

The above reference page give a solid example on implementation. Check out my implementation below that allows you add a featured YouTube video to your post.

hooks

add_action( 'add_meta_boxes', 'featuredVideo_add_custom_box' );
add_action( 'save_post', 'featuredVideo_save_postdata' );

add meta box

function featuredVideo_add_custom_box() {
    add_meta_box(  'featuredVideo_sectionid', 'Featured Video', 'featuredVideo_inner_custom_box', 'post', 'side' );
}

print box

function featuredVideo_inner_custom_box( $post ) {
    wp_nonce_field( plugin_basename( __FILE__ ), 'featuredVideo_noncename' );
 
    // show featured video if it exists
    echo getFeaturedVideo( $post->ID, 260, 120);   
 
    echo '<h4 style="margin: 10px 0 0 0;">URL [YouTube Only]</h4>';
    echo '<input type="text" id="featuredVideoURL_field" name="featuredVideoURL_field" value="'.get_post_meta($post->ID, 'featuredVideoURL', true).'" style="width: 100%;" />';
}

handle box post

function featuredVideo_save_postdata( $post_id ) {
 
    // check autosave
    if ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) 
      return;
 
    // check authorizations
    if ( !wp_verify_nonce( $_POST['featuredVideo_noncename'], plugin_basename( __FILE__ ) ) )
      return;
 
    // update meta/custom field
    update_post_meta( $post_id, 'featuredVideoURL', $_POST['featuredVideoURL_field'] );
}

helper function, displays YouTube video, which can also be used to display the YouTube video within your theme

function getFeaturedVideo($post_id, $width = 680, $height = 360) {
    $featuredVideoURL = get_post_meta($post_id, 'featuredVideoURL', true);
 
    preg_match('%(?:youtube\.com/(?:[^/]+/.+/|(?:v|e(?:mbed)?)/|.*[?&]v=)|youtu\.be/)([^"&?/ ]{11})%i', $featuredVideoURL, $youTubeMatch);
 
    if ($youTubeMatch[1])
        return '<iframe width="'.$width.'" height="'.$height.'" src="http://ww'.
               'w.youtube.com/embed/'.$youTubeMatch[1].'?rel=0&showinfo=0&cont'.
               'rols=0&autoplay=0&modestbranding=1" frameborder="0" allowfulls'.
               'creen ></iframe>';
    else
        return null;
}

and the final result