Have you ever tried to insert advertisements (or any bit of code really) into the WordPress post loop, then found that it will insert the banner after each post?   It really depends on what you are going for, but this usually will not be an ideal solution to placing advertisements between posts on your homepage.   If you’d like to place something only after the first post in the WordPress post loop, here is a quick hack you can do to tell WordPress to only display it after the first post.

Simply go to your themes homepage and look for the following code:

<?php endwhile; ?>

Immediately before this code, place the following code:

<?php if(!$show_ads){ ?>
Insert Code Here
<?php $show_ads = 1; } ?>

Obviously you’ll want to replace Insert Code Here with your code.  Told you it was easy!

Digg This! | Stumble it! | Add to Del.icio.us | | Print This! |

This guest post was written by John Pratt who blogs about blogging, WordPress, and his life as a webmaster. If you have webmaster or WordPress knowledge and are interested in writing a post for Hack WordPress, please contact us.

There are a lot of unethical “content spinning” plugins for Wordpress and other blogging platforms on the web. But for those of us with legitimate blogs, after about 100 posts your content starts to get lost. Most of it is still good, and most of us have multiple blogs as well. Why not “bring back” a post from the archive to the home page on a regular schedule and reuse that old content again? Before I had this plugin I longed for something that would effectively rotate my blog posts out of the archives and back onto the front page of my blog. Not every blog will have a need for this, but I have quite a few blogs, and I can’t always work on every one every day (or even every week). The blog paradigm means that the newest things are on the homepage scrolling down to the oldest, and when the content doesn’t change it makes you blog “stale”.

Being able to recycle your blog posts takes a marketing tip from fast food restaurants. Do you ever notice that certain things “come back” on a regular basis? Every year for Lent, all the fast food restaurants being back the “fish sandwich”. You see McDonald’s bring back the “McRib” and the “Monopoly Game” about once per year. They take things in and out of the rotation to keep it fresh, and if your blog posts stand the test of time, there’s no reason that they can’t be rotated too.

I have a fun site called “Top Jokes that’s been live with jokes for about 8 months or so. I used to posts a joke or more every day, in fact there are now more than 500 jokes. This type of site doesn’t pay very well, as far as a CTR, and the traffic isn’t so high either. But I don’t want to get rid of it because like all web real estate “it grows over time” - I just want to minimize the amount of time I spend on it. I’d like to post maybe a half dozen jokes per month and rotate old jokes from the archives to the homepage at the rate of one per day.

Enter the brilliant plugin by Dagon Design Scheduled Post Shift Plugin for Wordpress. It’s a very simple, very easy to use plugin. Once you install and enable it - just set the options:

scheduled post shift options

Just enter the number of hours between post shifts, and at that time it will rotate your oldest post in your Wordpress blog to your home page by changing the published date to current time. Once per day enter 24 hours, twice per day 12 hours, every two days enter 48 hours, etc. The second option you can leave blank, but if you enter a category ID only posts from that category will be rotated. You could use this to your advantage in an interesting way by creating a dozen or so posts, and give them dates from a year ago and assign them to a “sponsors” category. Then enable Scheduled Posts Shift for just the “sponsors” category every 24 hours (if you post every day) or whatever your post schedule is to have “recommended” or sponsored items cycle through your home page regularly. This could be a very interesting way to monetize your blog.

However you use it, Scheduled Posts Shift can help you to automatically recycle your WordPress blog posts and keep all that hard work and those archives you’ve built up over time producing both traffic and income for years!

If by chance you’re using data based permalinks - will need to remove them and use just the post (/%post%) so the URL of your posts doesn’t change when the old posts are “shifted” to the home page. Read How to change permalink structure seamlessly if that situation applies to you.

Digg This! | Stumble it! | Add to Del.icio.us | | Print This! |

Here are some WordPress links that I thought our readers may find useful.  They were all published over the past couple weeks.  Enjoy!

Digg This! | Stumble it! | Add to Del.icio.us | | Print This! |

Possibly my favorite feature introduced in WordPress 2.6 was the wiki-style document revisions.  You can now easily get access and/or restore old revisions.   It took a few days to get used to, but I have to say I really love it!

I’ve always felt that this feature was intended primarily for multi-author blogs and probably isn’t needed for most WordPress bloggers, as it only serves to grow your wp_posts database table.   If you are someone that would like to disable this feature, all you need to do is open your wp-config.php file and add the following code:

define('WP_POST_REVISIONS', false);

This should restore WordPress to handling posts the way it did in the WordPress 2.5 branch and earlier!

Digg This! | Stumble it! | Add to Del.icio.us | | Print This! |

If you’ve been with WordPress awhile, you’ll probably remember back in October of 2007 when Automattic purchased Gravatar.   The concept behind Gravatar had always been an incredible idea, but it had always lacked the time and resources needed to make it work.  Now that Automattic acquired Gravatar, it was pretty obvious that the service would be resurrected and would be a great fit for the WordPress platform.

Earlier this year when WordPress 2.5 came out, a shift was made in the WordPress community from the widely popular MyAvatars plugin (which uses MyBlogLog avatars) to Gravatars.   In addition to being built into WordPress.com blogs, we were also given the ability to build Gravatars into your WordPress.org blog.  But, did you know that WordPress.org blog owners can now also create your own custom default Gravatar image?

Over at Pro Blog Design, Michael has written a great tutorial explaining exactly how to add your own default Gravatar image, as well as provide some tips on how to make a good Gravatar default image.

In order to add the image you’ve made, you just need to take your Gravatar code and add the image URL right after the comma:

Before

<?php if(function_exists(’get_avatar’)){ echo get_avatar($comment, 50 );} ?>

After

<?php if(function_exists(’get_avatar’)){ echo get_avatar($comment, 50, 'http://www.hackwordpress.com/wp-content/themes/HackWordPressPro/images/nophoto.gif');} ?>

Great tip Michael!  You’ll want to click over to see Michael’s tips on creating a custom “No Gravatar” logo for your website.

Digg This! | Stumble it! | Add to Del.icio.us | | Print This! |

In my opinion, all blogs should have an archive page: It allows your readers to quickly browse your blog and find what they’re looking for, and this page is also very good for SEO.

Here’s how to create this page on a Wordpress blog:

Archive Wordpress Plugins

There’s many plugins which allows you to automatically create an archive page. The good thing is that you’ll have (almost) nothing to do, and the bad thing is that you will not be able to customize it a lot, or you’ll have to edit the plugin files, which is sometimes a bit too hard if you’re not a developer.

On my blog in French lyxia.org, I use the Smart Archives plugin.  Even if it gives me satisfaction, the loading time of the page is very long due to the amount of posts to be displayed simultaneously.

If you want to use a plugin, you shall also give a try to Clean Archives, or Extended Live Archives, which allows numerous personalizations.

Do it yourself

Wordpress allows you to create page templates, so it’s possible to create manually an archive page. This is what I chose to do on my blog in English, CatsWhoCode.com.

Before starting to code, you’ll have to choose between two different kinds of archive page. The first one will list all your posts, and will allow a direct access to every article you wrote. The only bad thing is that when your blog will have many posts, the list may be a bit too long.

The second template, which is better for blogs that have been online since more than one year, will list your posts monthly and by categories.

Your choice is made?  So let’s go coding!

First we’ll have to create a new file and name it archives.php. At the beginning of the file, paste the following lines:

<?php
/*
Template Name: Archive page
*/
?>

This php comment define a name for our template, and will later allows us to select it on Wordpress Dashboard, when we’ll create a new page.

First template: Listing all posts

<?php
$posts_to_show = 100; //Max number of articles to display
$debut = 0; //The first article to be displayed
?>
<?php while(have_posts()) : the_post(); ?>
<h2><?php the_title(); ?></h2>
<ul>
<?php
$myposts = get_posts('numberposts=$posts_to_show&offset=$debut');
foreach($myposts as $post) :
?>
<li><?php the_time('d/m/y') ?>: <a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></li>

<?php endforeach; ?>
</ul>

<?php endwhile; ?>

Second template: Archives by months and categories

<?php while(have_posts()) : the_post(); ?>
<h2><?php the_title(); ?></h2>

<h2>Monthly archives</h2>
<ul><?php wp_list_cats('sort_column=name&optioncount=1') ?></ul>

<h2>Categories</h2>
<ul><?php wp_get_archives('type=monthly&show_post_count=1') ?></ul>

<?php endwhile; ?>

After you chose one of the templates I shown you above and pasted it to your archives.php file, you just have to upload it on your wp-content/theme/yourtheme/ directory.

Then, in Wordpress dashboard, create a new page, name it “Archives” (or whatever you want) and select Archive page as page template.

That’s all! You now have an archive page, which is good for both your reader and search engines crawlers.

Digg This! | Stumble it! | Add to Del.icio.us | | Print This! |