Archive for the ‘Tutorial’ Category

Adding a Facebook “Like” Button to WordPress – the (Somewhat) Easy Way

Friday, April 23rd, 2010

UPDATE: I managed to write this into a plugin – Facebook Like Button

Since Facebook announced a few days ago that you would be able to use its OpenGraph technology to “like” pretty much anything on the Internet, I took it upon myself to test out a few solutions for adding a “Like” button on the site.

It turned out to be fairly easy, but not as easy as just adding a plugin and doing forth (at least, it’s not yet, anyway).

Our Plan of Action:

  1. Download and Install the plugin
  2. Editing the core file to allow for correct width and color scheme

Step 1: Downoading the Plugin

I looked through quite a bit of plugins to find this one, and I had to get it from his website because it’s an alpha release, but the Facebook Like Widget does it cleanly and with little fuss.

Step 2: Customizing the Plugin

OK.  Editors note: normally I do not advocate editing the core of a plugin.  Why? Because when you update (and you should!) it will over-write what you did.  However, since this is an alpha release, and I’m almost positive the next changes will allow you easily do these changes, I think once or twice is ok.

You’re going to want to click into Plugins > Editor, and choose the “Facebook Like Widget” plugin from the list.

There’s literally about 20 lines of code:

<?php
/*
Plugin Name: Facebook Like Widget
Plugin URI:
http://allanjosephbatac.com
Description: Add a Facebook ‘Like’ Button Widget to your post pages. Increase visitors!
Author: AJ Batac
Version: 0.1
Author URI:
http://allanjosephbatac.com
*/

function add_facebook_like($the_iframe = ”)
{
    $the_perma    = rawurlencode(get_permalink());
    $the_iframe    .= ‘<div id=”facebook_like”><iframe src=”
http://www.facebook.com/plugins/like.php?href=’.$the_perma.’&amp;layout=standard&amp;show-faces=true&amp;width=600&amp;action=like&amp;font=arial&amp;colorscheme=dark” scrolling=”no” frameborder=”0″ allowTransparency=”true” style=”border:none; overflow:hidden; width:600px; height:auto;”></iframe></div>’;
    return $the_iframe;
}

add_action(‘the_content’, ‘add_facebook_like’);
?>

The bold, color coded areas above show the areas you can change. The width corresponds to how wide your blog is.  if you don’t know, then just leave it at the default (450px) and you should be OK.  However, your friend’s “faces” won’t go to the edge of your content.  In yellow is the “color scheme”.  If you have a light background, choose “light”.  If you have a darker background, like my site, choose “dark”. 

That’s it – the like badge will show up at the bottom:

image

And will also show up on your friend’s “Recent Activity” stream:

Capture

Keep in mind, this is not the most elegant solution, but until others come, this is a great way to get it on your site quickly and with very little editing.

How to Create a Dynamic Sidebar Controlled with Custom Fields in WordPress

Wednesday, April 14th, 2010

OK, so it’s not the most original title in the world, but it gets the point across :)

I’ve been working with the fantastic Jeff Brown and the Way-FM crew to create a site for their Nashville presence that will allow them super-quick, easy content management and a place they can post local stories and events.  WordPress, of course, is the logical choice, but then they presented me with an interesting conundrum: make their “jock” bio pages fun and engaging.  And make it have all of their social bells and whistles on it.

I took up the challenge.

And honestly, it’s super-freakin’ easy to do.

Our to do list:

  • Define a global variable in WordPress that will carry outside of the post loop
  • Create the custom field, and set the key names
  • Create a template tag that will showcase only the custom field data I want
  • Create an IF statement to, if there’s nothing in the field, collapse the field (the cool part!)

Step 1: Define our Global Variable

A Global Variable (looks like this: $variable) is basically a proxy for some other piece of code.  When we set one, and we can set a variable to anything we want, we’re saying “Instead of saying this long random code string, we’re going to say one word and a dollar sign.  Makes for much easier querying in WordPress.

Look for the code line:

<?php if (have_posts()) : while (have_posts()) : the_post(); ?>

Right after that, add this line:

<?php global $globalvar; $globalvar = $post->ID; ?>

You can name it whatever you want, just make sure to carry the new name throughout the code.

Step 2: Create the custom fields

Remember how to create custom fields?  Below the post editor look for these boxes:

image

If you’ve never created a field, that will be blank.  Enter in your key (the name) and the value and hit “update”.  The yellow flash will tell you it was a success.  Remember that key name: it’ll come in handy later </resident Evil>

Step 3: Create a template tag to call the data.

I’m going to keep a standard format to these, just for ease of use.  I’ve formatted this like a normal sidebar widget is, just so I can have consistency between the main site and these special pages.

Head over to the sidebar.php file (or whatever file you want to drop this code into) in the Appearance > Editor. 

<?php $globalvarcheck=get_post_meta($globalvar, ‘keyname’, true); ?>

<li class=”widget”>
    <h4 class=”widgettitle”>Facebook</h4>
      <?php echo $globalvarcheck ?>

    </li>

get_post_meta is our tag of choice.  There are three, comma separated options: 1) Post ID, 2) key name, and 3) do we want to display it, or queue it in an array.  Basically, we call another global variable to specifically call the first variable as the post id, and give it the correct key name to make sure we call the right variable.

Step 4: Preventing Empty Widgets with an If Statement

But, Mitch, what happens if we don’t have a value set for a key? Never fear.  You can use a simple check with the same global variable to only display the data if that custom field has information in it. 

Here’s a facebook widget I developed (so you can drop in a Fan Page box) and showcase it on a particular page.  It shows the full IF statement with some example verbage:

<!–Facebook Widget Start–>
<?php $facebookcheck=get_post_meta($globalvar, ‘facebook’, true); ?>
    <?php if ( $facebookcheck ) { ?>

<li class=”widget”>
    <h4 class=”widgettitle”>Facebook</h4>
      <?php echo $facebookcheck ?>

    </li>
<?php  } ?>
<!–Facebook Widget End—>

Usage

Obviously, dropping in random social media widgets is a great way to use this, but I have a bonus for all you twitter-ites out there.  Ricardo González created a plugin called Twitter for WordPress, and it’s one of the few that uses template tags as a way of insertion (you see where this is going?):

<!–Twitter Widget Start–>
<?php $twittercheck=get_post_meta($globalvar, ‘twitter’, true); ?>
    <?php if ( $twittercheck ) { ?>

<li class=”widget”>
    <h4 class=”widgettitle”>Latest Tweets</h4>
     <?php twitter_messages($key_1_value = get_post_meta($twitterID, ‘twitter’, true), 5); ?>

    </li>
<?php  } ?>
<!–Twitter Widget End—>

I know that looks like a lot of code, but I basically embedded one template tag in another.  The first value in the twitter_messages tag is the global variable calling a twitter username.  The second calls the number of tweets.  Basically, enter in a twitter username, and if you do, this will display 5 tweets from it.  Pretty cool eh?

I can’t show the full site example because it’s not launched yet, but here’s a sneak peek at the new Way-FM site, and this code in action:

image

WordPress Plugin: Author Spotlight

Monday, March 22nd, 2010

I’ve been doing a lot of looking into using WordPress as a multi-author website/blog lately.  A few of my clients have requested the need to handle (elegantly) multiple authors, so (being fresh on my mind) I feel inclined to share.

One of the coolest plugin combinations I’ve come across recently is using Author Spotlight and Authors Widget in combination with a custom author template to create a really fun way to showcase authors both in the sidebar, on their own page, and on a single page.  The first two are easy, but the third one takes a small tweak to get things going.

The easiest way I’ve seen is to add a sidebar widget spot to the single post page with this code:

  <ul id=”spotlight”>
            <?php     /* Widgetized sidebar, if you have the plugin installed. */
                    if ( !function_exists(‘dynamic_sidebar’) || !dynamic_sidebar(2) ) : ?>
            <?php endif; ?>

   </ul>

Then, hit up your functions.php and make the necessary changes to add in a second (third, fourth, etc) sidebar:

<?php
if ( function_exists(‘register_sidebars) )
    register_sidebars(2,array(
        ‘before_widget’ => ‘<li id=”%1$s” class=”widget %2$s”>’,
        ‘after_widget’ => ‘</li>’,
        ‘before_title’ => ‘<h2 class=”widgettitle”>’,
        ‘after_title’ => ‘</h2>’,
    ));

?>

Finally, download and install Author Spotlight and drag it to your second sidebar.

You’ll have to do a bit of styling to get things looking nice (like the screenshot below), so here’s what I recommend:

image

#author_spotlight{
margin: 0;
list-style: none;
border: 1px solid black;
padding: 0 15px;
margin: 10px 0;
min-height: 150px;
}

#author_spotlight i a{
display: none;
}

#author_spotlight img{
float: left;
margin-right: 15px;
}

h4#author_name{
display: none;
}

#author_spotlight h2.widgettitle{
background-image: none !important;
padding-left: 0px !important;
}

Special thanks to Aaron, Mark, and Kelly over at The Periscope Group for letting me (aka, they just launched and I’m sending some traffic their way) take a peek inside his CSS code and use his site as an example.

How to Create a Slick Javascript Sliding RSS Reader in WordPress

Friday, March 19th, 2010

I’ve been learning lots of new WordPress tricks this past week.  Writing them down is two-fold win for me because 1) you guys get a look into how I do some of the stuff I do, and 2) I don’t forget how to do these tutorials later on when I need them again.  Yes, that can be a problem sometimes for me.  Don’t judge me.

Anyway, Scott Raynovich over at the Rayno Report wanted a fantastic way to showcase RSS feeds from around the web.  He wanted something that would allow more than four or five feeds without taking up the whole sidebar.

The result?  This really slick Accordion based feed sidebar:

image

Clicking on one of the titles…

image

Everything slides down to make room. 

It was actually really simple to create, and the best part: it’s widgetized!  That’s right, any feed that needs to be added in is simply added in as an RSS widget to a special sidebar.

So, onto the how-to!

Our process includes the following:

  1. Set up and Install the Accordion Script (and Google-Load jQuery)
  2. Set up a second sidebar (or third, or whatever number you have)
  3. Add the appropriate code to the sidebar.php file
  4. Add in a few widgets to test

Step 1: The Accordion Script

I know that there’s a jQuery-UI accordion script that’s floating around, but we’re going to be using a bit of a modified version that’s set up specifically for WordPress.  I like to pre-load via Google jQuery as well – takes some of the load off of the server and allows it to do its thing, letting Google fit the processing power for the actual framework.

Insert this code into your header:

<script type=”text/javascript” src=”http://ajax.googleapis.com/ajax/libs/jquery/1.4.1/jquery.min.js”></script>
<script type=”text/javascript”>
function initMenus() {
    $(‘ul#accordion li ul’).hide();
    $.each($(‘ul#accordion’), function(){
        $(‘#’ + this.id + ‘.expandfirst ul:first’).show();
    });
    $(‘ul#accordion li h2.widgettitle’).click(
        function() {
            var checkElement = $(this).next();
            var parent = this.parentNode.parentNode.id;

            if($(‘#’ + parent).hasClass(‘noaccordion’)) {
                $(this).next().slideToggle(‘normal’);
                return false;
            }
            if((checkElement.is(‘ul’)) && (checkElement.is(‘:visible’))) {
                if($(‘#’ + parent).hasClass(‘collapsible’)) {
                    $(‘#’ + parent + ‘ ul:visible’).slideUp(‘normal’);
                }
                return false;
            }
            if((checkElement.is(‘ul’)) && (!checkElement.is(‘:visible’))) {
                $(‘#’ + parent + ‘ ul:visible’).slideUp(‘normal’);
                checkElement.slideDown(‘normal’);
                return false;
            }
        }
    );
}
$(document).ready(function() {initMenus();});
</script>

The first script tag loads jQuery, the second the accordion script.  Notice how we’re targeting ul#accordion as the feed sidebar, and h2.widgettitle as the trigger.

Step 2: Adding a Second Sidebar into the Functions

Head into the theme editor and navigate to your theme functions file (functions.php).  We’re going to 1) make sure there’s widgetized sidebar code inside and 2) make sure that it calls for more than one sidebar.

If you have:

<?php
if ( function_exists(‘register_sidebars) )
    register_sidebar(array(
        ‘before_widget’ => ‘<li id=”%1$s” class=”widget %2$s”>’,
        ‘after_widget’ => ‘</li>’,
        ‘before_title’ => ‘<h2 class=”widgettitle”>’,
        ‘after_title’ => ‘</h2>’,
    ));

?>

or something similar, you’re already widgetized.  Change that code to what comes next to get it multiple-sidebar ready.  If you aren’t widgetized, add in this bit of code at your own risk:

<?php
if ( function_exists(‘register_sidebars’) )
    register_sidebars(2,array(
        ‘before_widget’ => ‘<li id=”%1$s” class=”widget %2$s”>’,
        ‘after_widget’ => ‘</li>’,
        ‘before_title’ => ‘<h2 class=”widgettitle”>’,
        ‘after_title’ => ‘</h2>’,
    ));

?>

This sets up two sidebars.  The second sidebar will be where our feeds go.

Step 3: Adding a Second Sidebar

Save your file and switch to sidebar.php.  If you’re widgetized you should see something like this:

  <ul id=”sidebar”>
            <?php     /* Widgetized sidebar, if you have the plugin installed. */
                    if ( !function_exists(‘dynamic_sidebar’) || !dynamic_sidebar() ) : ?>
            <?php endif; ?>

   <!—OTHER SIDEBAR STUFF—>

   </ul>

Somewhere in that file (either before the if statement, or after), you want to add in this:

<li class=”feedreader”>
  <h2 class=”widgettitle”>RSS Feeds</h2>
  <ul id=”accordion” class=”collapsible”>
                <?php     /* Widgetized sidebar, if you have the plugin installed. */
                    if ( !function_exists(‘dynamic_sidebar’) || !dynamic_sidebar(2) ) : ?>
            <?php endif; ?>
</ul></li>

This adds in a widget that will serve as the container for the accordion file.  Then, we have another unordered list that will contain the feed widgets we drop in.

You should have something that looks like this:

  <ul id=”sidebar”>
            <?php     /* Widgetized sidebar, if you have the plugin installed. */
                    if ( !function_exists(‘dynamic_sidebar’) || !dynamic_sidebar() ) : ?>
            <?php endif; ?>

<li class=”feedreader”>
  <h2 class=”widgettitle”>RSS Feeds</h2>
  <ul id=”accordion” class=”collapsible”>
                <?php     /* Widgetized sidebar, if you have the plugin installed. */
                    if ( !function_exists(‘dynamic_sidebar’) || !dynamic_sidebar(2) ) : ?>
            <?php endif; ?>
</ul></li>

   <!—OTHER SIDEBAR STUFF—>

   </ul>

That will insert your new sidebar. 

Step 4: Adding Widgets

After that, the last thing to do is to add in some feeds to test out in the Widgets panel of the Appearance tab.  Add in two or three to get a test, then view the page.

Any styles can be applied to make things look better, and here’s what you can expect to be able to change:

ul#accordion – controls the entire accordion box

ul#accordion h2.widgettitle – controls what the title feed of the individual feeds looks like

ul#accordion li li – individual feed items

ul#accordion li a – individual feed link properties

Head over to the Rayno Report to see it in action (and read his content – LOTS of great tech tips from the financial side).

How to Make a Royally Awesome Author Template in WordPress

Wednesday, March 17th, 2010

I’ve been trying some new stuff with my client’s websites as of late.  I wanted something where a multi-blog site could get the most out of as few plugins as possible, and still have a really awesome way to display their author’s main information.  But, the information they ask for doesn’t have everything.  What about twitter profiles? Facebook links?

There’s a few things we can do to enhance the process.

We’re going to be accomplishing a few things here:

  1. Building an author.php template to take care of author links
  2. Downloading and installing any necessary plugins
  3. Customizing the author profile with new fields.
  4. Calling those new variables in the author template.

Step 1: Building an Author.php template

So, WordPress’ structure for templates goes as follows:

  • author.php
  • archive.php
  • index.php

It looks for files (top to bottom) and uses whichever one it finds to do its bidding.  Since default templates don’t usually have one, we’re going to build an author.php file.  To start with, let’s make it look something like this:

<?php get_header(); ?> <div id="content" class="narrowcolumn"> <!-- This sets the $curauth variable --> <?php if(isset($_GET['author_name'])) : $curauth = get_userdatabylogin($author_name); else : $curauth = get_userdata(intval($author)); endif;  ?> <h2>About: <?php echo $curauth->nickname; ?></h2> <dl> <dt>Website</dt> <dd><a href="<?php echo $curauth->user_url; ?>"><?php echo $curauth->user_url; ?></a></dd> <dt>Profile</dt> <dd><?php echo $curauth->user_description; ?></dd> </dl> <h2>Posts by <?php echo $curauth->nickname; ?>:</h2> <ul> <!-- The Loop --> <?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?> <li> <a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link: <?php the_title(); ?>"> <?php the_title(); ?></a>, <?php the_time('d M Y'); ?> in <?php the_category('&');?> </li> <?php endwhile; else: ?> <p><?php _e('No posts by this author.'); ?></p> <?php endif; ?> <!-- End Loop --> </ul> </div> <?php get_sidebar(); ?> <?php get_footer(); ?>

What this does is set up the author variables, calls some basic variables like name, url, and a bio (description), and displays the last X posts (defined by the number set in the options menu).  We’re going to be modifying this quite a bit, but this gives us a good start point.

Save this as author.php, send it to your server via FTP, and open it in your theme editor to make sure it looks OK.

Step 2: Plugins We’ll Need

Actually, we’ll only need one plugin to really get the most out of this: the Authors Widget plugin. This gives us a really cool widget that pulls the author’s name and gravatar (if you choose) and displays post counts (also if you choose – lots of options).  It’s a fast way to showcase all the authors in the sidebar.  If you click on the author’s name, it takes you to their author page (which is what you just build [author.php]).

Step 3: Adding Fields to the User Profile

Open the theme editor and edit (or create an upload if you don’t have one) the functions.php file.  This file has lots of drop-in options you can get from Google to enhance your theme.  Widgetized sidebar code goes here too, so most people have one already.

Drop in this data:

add_action( 'show_user_profile', 'my_show_extra_profile_fields' );
add_action( 'edit_user_profile', 'my_show_extra_profile_fields' );

function my_show_extra_profile_fields( $user ) { ?>

<h3>Extra profile information</h3>

<table class="form-table">

<tr>
<th><label for="twitter">Twitter</label></th>

<td>
<input type="text" name="twitter" id="twitter" value="<?php echo esc_attr
( get_the_author_meta( 'twitter', $user->ID ) ); ?>" class="regular-text" /><br />
<span class="description">Please enter your Twitter profile URL.</span>
</td>
</tr>

<tr>
<th><label for="facebook">Facebook</label></th>

<td>
<input type="text" name="facebook" id="facebook" value="<?php echo esc_attr
( get_the_author_meta( 'facebook', $user->ID ) ); ?>" class="regular-text" /><br />
<span class="description">Please enter your facebook profile URL.</span>
</td>
</tr>

<tr>
<th><label for="linkedin">LinkedIn</label></th>

<td>
<input type="text" name="linkedin" id="linkedin" value="<?php echo esc_attr
( get_the_author_meta( 'linkedin', $user->ID ) ); ?>" class="regular-text" /><br />
<span class="description">Please enter your linkedin profile URL.</span>
</td>
</tr>

</table>
<?php }

add_action( 'personal_options_update', 'my_save_extra_profile_fields' );
add_action( 'edit_user_profile_update', 'my_save_extra_profile_fields' );

function my_save_extra_profile_fields( $user_id ) {

if ( !current_user_can( 'edit_user', $user_id ) )
return false;

/* Copy and paste this line for additional fields. Make sure to change 'twitter' to the field ID. */
update_usermeta( $user_id, 'twitter', $_POST['twitter'] );
update_usermeta( $user_id, 'facebook', $_POST['facebook'] );
update_usermeta( $user_id, 'linkedin', $_POST['linkedin'] );
}

This dataset is for adding a twitter, linkedin, and facebook profile link box to each user profile.  You can customize it however you need to, just add:

<tr>
<th><label for="twitter">Twitter</label></th>

<td>
<input type="text" name="twitter" id="twitter" value="<?php echo esc_attr( get_the_author_meta
( 'twitter', $user->ID ) ); ?>" class="regular-text" /><br />
<span class="description">Please enter your Twitter profile URL.</span>
</td>
</tr>

and change the values from “twitter” to whatever you want the field to be called.  Also, add a line like this:

update_usermeta( $user_id, 'linkedin', $_POST['linkedin'] );

under the rest.  That will allow the data to be saved.

4. Changing the Author Template

Now that we have some really cool custom values, let’s edit our template a little bit.  We’re going to change it to this:

<!-- This sets the $curauth variable -->

<?php
if(isset($_GET['author_name'])) :
$curauth = get_userdatabylogin($author_name);
else :
$curauth = get_userdata(intval($author));
endif;
?>
<div class="author_bio">
<h2><span><?php echo $curauth->first_name; ?> <?php echo $curauth->last_name; ?></span></h2>
<div class="floatLeft" style="margin-right: 10px"><?php echo get_avatar($curauth->ID, $size = '96'); ?></div>

<p><?php echo $curauth->user_description; ?></p>
<div class="clear"></div>
<h2 class="connectwith"><span>Connect with <?php echo $curauth->first_name; ?>:</span></h2>
<div class="clear"></div>

<ul>
<li><a class="linkedin" href="<?php echo $curauth->linkedin; ?>">linkedin profile</a></li>
<li><a class="facebook" href="<?php echo $curauth->facebook; ?>">facebook profile</a></li>
<li><a class="twitter" href="<?php echo $curauth->twitter; ?>">twitter profile</a></li>

</ul>
<div class="clear"></div>
<h2 class="postsby"><span>Posts by <?php echo $curauth->first_name; ?>:</span></h2>
</div>
<!-- The Loop -->

<?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
<div class="post">
<h2 id="post-<?php the_ID(); ?>"><a href="<?php the_permalink() ?>" rel="bookmark"
title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_title(); ?></a></h2>

<div class="entry">
<?php the_content('<p class="serif">Read the rest of this entry &raquo;</p>'); ?>
<div class="clear"></div>
<div class="tags"><?php the_tags( '<p>Tags: ', ', ', '</p>'); ?></div>

</div>

</div>

<?php endwhile; else: ?>
<p><?php _e('No posts by this author.'); ?></p>

<?php endif; ?>

Notice the changes we’ve made:

  • We’ve added the user’s first name and last name.  This will allow users to know exactly who the author is
  • We’ve added the gravatar by user ID and given it a right margin to prevent text-bumping
  • There’s a new section called “Connect With X” – it has an unordered list that contains the three fields we just created, echoed in a hyperlink to allow for automatic linking to profiles.

You can style this, or modify it, however you want, but this is a fairly simple technique to allow authors to have an automatically generated page with 1) their information, 2) their picture/avatar, and 3) their latest posts.

CSS Reset

Wednesday, November 11th, 2009

A lot of people are curious as to what CSS reset I use (most of those people are in my Intermediate Web Design class that I teach on Tuesday nights).  Fear not, for i am posting my favorite reset template here!

@charset "utf-8";
/* CSS Document */

/*--------------CSS RESET-------------*/

/* Global Defaults */
html, body {
  margin: 0px;
  padding: 0px;
  border: 0px;
}
body {
	font: 1em/1.25 Arial, Helvetica, sans-serif;
}

*{
outline: 0px;
}

/* Headlines */
h1, h2, h3, h4, h5, h6 {
	margin: 0;
	padding: 0;
	font-weight: normal;
	font-family: Arial, Helvetica, sans-serif;
	color: #545049;
}

/* Text Styles */
p, th, td, li, dd, dt, ul, ol, blockquote, q, acronym, abbr, a, input, select, textarea {
	margin: 0;
	padding: 0;
	font: normal normal normal 1em/1.25;
}
blockquote {
  padding: 0 1.25em
}
q {
  font-style: italic;
}
acronym, abbr {
  cursor: help;
  border-bottom: 1px dashed;
}
small {
  font-size:.85em;
}
big {
  font-size:1.2em;
}

/* Links and Images */
a, a:link, a:visited, a:active, a:hover {
	text-decoration: underline;
	color: #FFF;
}
img {
  border: none;
}

/* Tables */
table {
	margin: 0;
	padding: 0;
	border: none;
	text-align: left;
}

/* Forms */
form {
  margin: 0;
  padding: 0;
  display: inline;
}
label {
cursor: pointer;
}

/* Common Classes */
.clear { clear: both; }
.floatLeft, .alignleft { float: left; }
.floatRight, .alignright { float: right; }
.textLeft { text-align: left; }
.textRight { text-align: right; }
.textCenter { text-align: center; }
.textJustify { text-align: justify; }
.blockCenter { display: block; margin-left: auto; margin-right: auto; } /* remember to set width */
.bold { font-weight: bold; }
.italic { font-style: italic; }
.underline { text-decoration: underline; }
.noindent { margin-left: 0; padding-left: 0; }
.nomargin { margin: 0; }
.nopadding { padding: 0; }
.nobullet { list-style: none; list-style-image: none; }

ul ,ol{
	margin-left: 25px;
}

.post ul, .post ol{
margin-bottom: 10px;
}

Can SEO and Design Go Hand in Hand? (Part 1: H Tags)

Sunday, September 20th, 2009

I have clients all the time ask, “How is the new design going to help my traffic?”  Honestly, since design and content are supposed to be separate, a new design shouldn’t affect traffic in its purest sense.  But, a good designer can implement techniques that will affect Google’s view of a website, without even messing with the meta data or content.

This sort of “natural SEO” starts at the core of the site, in the code itself.

Use Proper Tags

Typically, your H1 through H6 tags are saved for the most important parts of the site. But proper positioning can guarantee that the most important content in the site is how the search engines index.  H1 tags are the most important, with H2 through H6 following closely behind.

Structure may vary from designer to designer, but mine typically goes like this for a corporate site (blogs, of course, have a different need):

The H1 tag gets put onto the logo, with the name of the site.

H2 tags are reserved for page titles, post titles, and search results.

H3 tags are sub headings (like the one above).

H4 tags are used for special points or callouts.

If I needed them, the H5-H6 tags would be used accordingly, but I honestly rarely use them unless I’m doing an outline.

Once the tags are implemented into the design, the process is automatic – as you add content, the tags work automatically.

Beach Blogging 101 – Session 2: Plugin and Unwind

Tuesday, August 18th, 2009

OK… so let me say first off that it’s not totally my fault that I didn’t get to finish my session last week.  The internet access in the condo we were staying in was nothing less than horrible (it was a great condo otherwise, but let’s just say that if it was online it didn’t get done very fast).  Mount on top of that the fact the nearest Starbucks was 25 minutes in either direction and you have yourself a 100 percent valid excuse as to why I didn’t post last week.

Yeah… So… sorry about that.

At any rate, I’m back in the land of Wi-Fi with my in-laws in Alabama and wanted to continue the vacation atmosphere a little bit.  Therefore, the posting series will continue as warranted!

The last post was a sure-fire way to make sure your blog was up to date with the latest patches (which, before the post and during my vacation, I was victim of a useless [but still annoying] bug that caused my password to be able to be reset from anywhere).  Needless to say I upgraded as soon as I could.

Today I’m going to be talking about 3 plug-ins that rock my world – ones that go on 95% of every WordPress installation that I do.  Well, actually there’s at least 6 to 10, but this is the short list.  Also, there’s one I’ll be going in depth about – All In One SEO (but that’s another post altogether).

So, without further ado, let’s get to it! These plug-ins are in no particular order, so don’t think I’m playing favorites – they all serve their purpose!

Plugin 1: WP-GreetBox

WP-Greetbox is a fun little plugin that does what every good blog should: calls the user to a specific action.  But, it’s hard to call people to action when their situation (or referring website) is different.  WP-GreetBox fixes that problem by detecting the site a person comes from, acknowledging their visit, and giving them a specific call to action based on that referral.  Coming from digg?  “Digg this site!” Visiting from StumbleUpon? “Be awesome and click the thumb-up button on your way out!”  Coming from anywhere else?  “Hey, welcome, subscribe to the feed”.  You can see it in action on this very blog at the top if you’ve come from a referring site such as Twitter or Google.

Plugin 2: Redirection

This is one of those “plug-ins in disguise”.  It’s actually a 3-in-1 plug-in that serves many purposes.  It’s main purpose is to redirect permalinks from an old blog or to funnel traffic through to a mis-wired connection.  Example: You change your permalink structure but one post is still getting traffic to its old permalink, and it’s throwing a 404 error.  The plug-in will tell you its logging the 404 error and will allow you to set that permalink up to redirect to the right place.

Of course, this also means it’s a built-in URL shortner.

http://www.studionashvegas.com/twitter/ for example – click on it and see where it goes ;)

Plugin 3: TweetMeme Button

TweetMeme’s retweet button is the new Digg button for blog posts.  It not only puts a really handy way to tweet out a site’s name and post link, but it shows you how many have been placed using said button (or any that turn up on the URL shortening service you set up).

Beach Blogging 101 – Session 1: Relax, Unwind, and Upgrade

Sunday, August 9th, 2009

If you didn’t figure it out from my tweets or last post, I am currently relaxing in Destin, FL (and at this moment, horribly sun-burnt – this is why geeks don’t get in the sun!).  I told myself I would do a blog post a day because I wanted to get into a daily routine of posting again, but then I asked myself… Why would I want to “work” on stuff like that while I’m on vacation?  It’s fun for me, and one of the problems during my day job is that I don’t get a lot of time otherwise to do it.

So, to me, this is a vacation: sitting at a Starbucks, relaxing, and working on a blog post.

And that’s when it hit me: I wonder how many other people have the same problem I have?  How many people have neglected their blog because they don’t have time to maintain it?  How many people have old WordPress installations that need upgrading, or are still running plugins from last year because they don’t have time to look up new ones?

Well, this week I’m going to take 6 days (today + this week, until Saturday, when we leave the beach) to share a little of my vacation with you, and help you get your blog into the shape it needs to be in.

And it starts with an upgrade.

If you aren’t running WordPress 2.7, we’ll start with you (you poor souls – you don’t know what you’re missing). You want to FTP the following plugins into your installation:

WP-DB-Backup

WP Automatic Upgrade

If you’re running WordPress 2.7 or later, then install WP-DB-Backup from the plugin installation menu on the left sidebar (plugins > add new).

Once it’s installed, head to Tools > Backup.

image

You’ll see a list of all of your tables.  For time sake, check the two on the left, and the important ones to you on the right.  Usually it tells you want the plugin is before it tells you the data (lifestream_event), so pick the important ones.

image

In the backup options, download the backup to your computer and hit Save once the dialog box comes up.  While you’re at it, head back in and schedule a weekly backup to be sent to your email account.  That way, if something happens, you’re covered.

Once that’s done, WP 2.6 users need to activate the automatic upgrade plugin and follow the instructions on screen.  It’ll walk you through the entire process, and will tell you exactly what to do.  I don’t have a blog running WordPress 2.6, or I would show you screenshots, but rest assured that backup you made can help if things go haywire.

For you 2.7 people, just hit the upgrade button at the top, and choose to upgrade now.  Everything will run in the background.  You really have no excuse not to upgrade if you’re running anything above 2.7

image

image

image

Those are actual upgrade screens from when I wrote this post.  I did it, while I was writing a post.  Was that really so hard?

Tune in tomorrow when I go over a few new plugins that have been release that will change the way people look at your blog.  Wednesday is SEO day as I talk about All-in-one SEO.  Thursday and Friday… well, why don’t you tell me?

I want to know what things on your blog go neglected because you don’t have time to fix it (or you don’t have time to learn how to use it/fix it).  The top comments on here and on Twitter will be covered Thursday and Friday.

Good luck with your upgrade, and have a happy fun time at the beach.  I leave you with… the Sand-Gator!

photo

No, it’s not night – the sun was SO bright my iPhone took a bad picture.  We made this gator this afternoon out of Sand – that’s why my legs are so sunburnt (kneeling down in the sand to sculpt it).

Displaying Comment Number Next to Posts

Wednesday, July 29th, 2009

A lot of people have commented on my new design how they love the comment bubble next to the post title.  It’s a great way to foster communication and showcase how many people are talking on your site.   So, if you want to add the same functionality to your site, here is the fastest way to do it!

image

First, you should note in your “index.php” file some code that looks something like this:

<h2 class="posttitle"><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_title(); ?></a></h2>

To break that down, this is a H2 that inserts an automatic link to the post (<?php the_permalink() ?>) and automatically grabs the title from the post (<?php the_title(); ?>).

To put this in your own blog, ou can either start with your own comment bubble design or grab this one:

[link to comment bubble]

I’ve included the PSD so you can change the color as you need to.  You can either add in a background color or save it as a PNG file with transparency – it works either way. Save and upload your comment bubble (JPG, PNG, or GIF only!) either via FTP or the Media Uploader and save the hyperlink – you’ll need it in a second. Head into your theme editor and look for the above code.  Right above it, insert this code:

<div class="commentbubble"><?php comments_number('0', '1', '%'); ?> </div>

To clarify, this adds a div container with the “commentbubble” and inserts the code to call the comments.  The ‘%’ is a variable number that calls any number that’s not 0 or 1.

Finally, add the CSS into your stylesheet:

.commentbubble {
    background-image: url(URL-GOES-HERE);
    height: 37px;
    width: 49px;
    color: REPLACE WITH COLOR;
    font-size: 30px;
    text-align: center;
    padding-top: 5px;
    margin-right: 13px;
    float:left;

}

Save the edits, and preview.  It should put the comment bubble right next to the title.  If you are having trouble having your content text or pictures wrapping around the bubble with the title, right after the commentbubble div, put this code:

<div style=”clear:both”></div>

This is a clearing div that will stop the text-wrapping.