When it comes to Search Engine Optimization for your WordPress powered website or blog there are 2 main choices: All In One SEO Pack and Platinum SEO Pack. To help you make an informed decision on which to use I have compiled a comparison of the plugins’ features.

Feature Comparison

Feature All In One SEO Platinum SEO
Canonical URLs
Overwrite Titles
Automatically Generate Meta Tags
Automatic 301 Redirects
Support for Spider Specific Meta Tags (noindex, noarchive, etc)
Auto Meta Plugin Compatible
Ultimate Tag Warrior Plugin Compatible

As can be seen the two plugins contain the same base SEO functionality with the Platinum SEO Pack having a few additional options that are mainly used by advanced SEO optimizers.

Plugin Usability

The main configuration screen of the two plugins are almost identical with the exception of a few varying options and that the All In One SEO Pack screen displays ads front and center to donate and for buying WordPress themes as can be seen in the below screen shot.

The Platinum SEO Pack Plugin however displays the normal links navigation across the top that can be found in most WordPress plugins. The page / post level editors for the two plugins however don’t contain any real differences beyond the additional META tag support options that is available only in Platinum SEO Pack.

Which SEO Plugin should you use?

Simply put in my opinion the best SEO Plugin you can have at the moment is Platinum SEO Pack. This Plugin is easy to use contains all the SEO features your site will require and also doesn’t contain annoying advertisements like the All In One SEO Pack plugin. If you are currently using the All In One SEO Pack Plugin don’t worry switching is easy as the Platinum SEO Pack is able to import your settings from the All In One SEO Pack.

Resources

, , , ,

Until the release of WordPress 3.0 due out later in the year, creating a sub navigation is still a somewhat obscure and tricky task. To hopefully shed some light on how to create a Sub Navigation for your own needs I am going to walk-through how you can output a pages child or sub pages. In simple terms how to display a second level navigation in your sidebar.

How to get Sub Pages

In WordPress the easiest way to get the a page’s child pages is to use the get_pages function. This function allows you to specify that you want the children of a page by using the child_of and parent parameters. When called this function returns an array that you can utilize to iterate over and output the child pages.

$child_pages = get_pages('child_of='. $post->ID; . '&parent=' . $post->ID;);

The $post variable is used in WordPress templates to denote the current post or page. We utilize the ID property to specify we want returned all pages that are children of the current page.

How to output the pages in a list

To output a list of the sub pages we can iterate over the children and output the page titles and links in a list by using the get_page_link function and the ID and post_title properties of the returned Page object.

echo '<ul class="subNav">';
    foreach( $child_pages as $c_page ) {
    echo '<li><a href="' . get_page_link($c_page->ID) . '">' . $c_page->post_title . '</a></li>';
}
echo '</ul>';

The full example

Using the above code we will be executing the code on all website pages including posts and categories. To limit the execution to only pages we can utilize the is_page function. As we want to display the secondary navigation when we are on the parent page or child page we will need to check the current page to determine if we are on a root page or child page by using the post_parent property. Using this we can determine if we need to get the children of the current page or the children of the page’s parent. Doing so allows us to consistently output a Sub Page Navigation as can be seen here.

if( is_page() ) {
    $the_ID = $post->ID;
    $i_page = $post;
    if( $post->post_parent ) {
       $the_ID = $post->post_parent;
       $i_page = get_page($the_ID);
    }
 
    $child_pages = get_pages('child_of='. $the_ID . '&parent=' . $the_ID);
 
    if( count($child_pages) > 0 ) {
        echo '<li class="widget"><h2><a href="' . get_page_link($the_ID) . '">' . $i_page->post_title . '</a></h2><ul>';
        foreach( $child_pages as $c_page ) {
            echo '<li><a href="' . get_page_link($c_page->ID) . '">' . $c_page->post_title . '</a></li>';
        }
        echo '</ul></li>';
    }
}
, , , , ,

WordPress has many nice built in features and helper functions for us to use in our websites. Some of the basic conditional functions like is_page, is_single, and is_home are perhaps the most versatile and useful to developers and site owners. These functions simply return true or false for if you are on a page, post, or the home page respectively. However they allow you to easily define custom sidebars and content blocks depending on where the user is on your site.

A basic example would be that you have decided that on your home page you would like to display a random post to the user. However when the user is looking at a post you want to display a post in the same category of the post being viewed. To accomplish this you can utilize the conditional tags is_single, and is_home. The logic shown below simply tests if the current page being displayed is the home page if so it outputs a random post, otherwise if it is a single page (post) it outputs a post from the same category of the current post being viewed.

<?php
// check if on home page
if (is_home()) {
    $rand_posts = get_posts('numberposts=1&orderby=rand');
     foreach( $rand_posts as $rpost ) :
?>
 
        <div>
            <h3 ><a href="<?php echo get_permalink( $rpost->ID ); ?>" target="_self"><?php echo get_title($rpost->ID); ?></a></h3>
            <div><?php echo get_post_meta($rpost->ID, 'teaser', true); ?></a></div>
            <a href="<?php echo get_permalink( $rpost->ID ); ?>" target="_self">Learn More Now &raquo;</a> 
	</div>
 
<?php	
    endforeach;
// test for single post
} else if (is_single()) {
 
     // get post categories
    $categories = get_the_category();
    $cats = array();
    foreach( $categories as $category ) {
             $cats[] = $category->cat_ID
    }
 
     $rand_posts = get_posts(array( 'numberposts' => 1, 'orderby' => 'rand', 'category__in' => $cats, 'exclude' => $post->ID) );
     foreach( $rand_posts as $rpost ) :
 
 
?>
 
        <div>
            <h3 ><a href="<?php echo get_permalink( $rpost->ID ); ?>" target="_self"><?php echo get_title($rpost->ID); ?></a></h3>
            <div><?php echo get_post_meta($rpost->ID, 'teaser', true); ?></a></div>
            <a href="<?php echo get_permalink( $rpost->ID ); ?>" target="_self">Learn More Now &raquo;</a> 
	</div>
 
<?php	
    endforeach;
} 
?>

This is one example of how you can utilize these tags. You could use them to determine if ads should be shown or which ones, changing layouts, or any number of ways.

Resources

, , , , , , ,

When writing a post to your WordPress powered blog or website have you ever wished you could split it up into multiple pages? The good news is that you can WordPress comes by default with the ability to create paginated posts by use of the Page-Link tag. This tag notifies WordPress that the following content should be on different page then the proceeding content.

The tag is used by simply inserting the text <!–nextpage–> into your post. There used to be a button to make this task easier on the user but it was removed to clean up the tools bar. You may find that this tag is not working for you in your site, the reason for this is that the theme you are using failed to implement the Page-Link function into their templates to display the pages. You can correct this by calling the wp_link_pages function in your single post template.

<?php wp_link_pages(); ?>

You can fully customize the page link by the usage of various parameters including before, after, next_or_number, and other self explanatory options. For a full list of options check out the Styling Page-Links page of the WordPress Codex.

, , , , , ,

Very often when developing a WordPress powered blog or website you may find that you need to add custom features. One of the most common feature requests that I have come across is to add an image to the excerpts that get displayed on the main posts/articles page. Some people will try to utilize the excerpt to have the image display but there is a much easier way, the Custom Fields feature of WordPress.

The Custom Fields feature is used to add properties to your posts that you can then use in your template files. The default Custom Fields interface provided by WordPress is pretty basic in that you can enter name value pairs where you can put anything you want as a value.
WordPress Custom Fields Example

To make using Custom Fields easier I would suggest utilizing a plugin such as Custom Field Template. This plugin allows you to create templates with defined fields for you to easily create your custom properties to your posts. In addition it enables you to have drop downs, text fields, text areas, and even the media hook in to insert images from your media content or upload them from your computer.
WordPress Custom Field Template

With the introductions to Custom Fields out of the way lets get right into an example on how to enhance your blog using them.

Example : Displaying an image with your blog excerpts

The simplest way to display an image in your blog excerpts is to create a custom field that will hold the image html that you want to display. If using the Custom Field Templateplugin then set the media to true so you can use the built in WordPress media tool to choose and modify your image. Lets assume for our purposes we named this property “img_thumb”. The first step is to identify the template(s) you will need to modify, in this example we will be modifying the main template responsible for showing the blog posts. Lets assume that our excerpts are displayed similar to the following sample code:

<div class="content">
    <h3>
        <a class="link" href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title(); ?>"><?php the_title(); ?></a>
    </h3>
    <div class="entry"><?php the_excerpt(); ?></div>
</div>

In this basic sample we are displaying the post title followed by excerpt. If we wanted to enhance this code to show the thumbnail image then we would have to first obtain the custom fields for the posts using the get_post_custom method, that returns an associated array of all the custom fields for the post.

<?php $custom_fields = get_post_custom(); ?>

Now that we have obtained the custom fields we can use them in our template. Lets modify the template so that we insert the image into our post prior to displaying the excerpt.

<?php $custom_fields = get_post_custom(); ?>
<div class="content">
    <h3>
        <a class="link" href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title(); ?>"><?php the_title(); ?></a>
    </h3>
    <div class="entry"><?php echo $custom_fields['img_thumb'][0]; ?><?php the_excerpt(); ?></div>
</div>

It is important to note the use of the [0] 0 index on the custom field property. As Custom Fields allow for multiple values for the same name it is important to use the index to specify the use of the value. This code above will now display the image in your blog posts. However you may have it so that you don’t have a image for each post, in that case you will want to check if the property exists before using it. If wanted you could even put in a default image to be displayed if a value isn’t entered.

<?php $custom_fields = get_post_custom(); ?>
<div class="content">
    <h3>
        <a class="link" href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title(); ?>"><?php the_title(); ?></a>
    </h3>
    <div class="entry">
        <?php if( $custom_fields['img_thumb'][0] != '' ) {
            echo $custom_fields['img_thumb'][0]; 
        } else { ?>
            <img src="http://www.example.com/wp-content/uploads/2010/02/test.jpg" alt="Alternate Text" title="Image Title" width="114" height="180" />
        <?php } ?>
        <?php the_excerpt(); ?>
    </div>
</div>

You have now enhanced your blog to display an image with your post excerpts. There are an unlimited number of ways to use custom fields in your blog from displaying special content and different layouts. Take the time to determine common content in your posts and then use Custom Fields to save and display this information in the format you need.

Resources

, , , , ,