Have you ever wondered how exactly you could choose which categories do and which don’t display your advertisements?   Maybe you have a Sponsored Review category and want to make sure that all posts filed in that category don’t display any ads.

This is something that you as a user of WordPress have the ability to do without to much effort.  What you need to do is paste the following code into your blog around your advertisement code:

<?php if ( !in_category(10) && !in_category(11) ) { ?>

This is your existing advertising code.

<?php } ?>

Where it says 10 and 11 you will want to place the number assigned to your categories that you want to censor advertisements from. You can repeat where it says ’&& !in_category(12)’ as needed until you’ve censored all categories.

Enjoy!

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

Depending on the type of WordPress blog you have, you may often find that you are writing a series of posts and want your readers to have easy access to the other posts in your series. Others may find that they like to break their posts into several individual parts, but want the readers to see that these posts are linked together.

This can be accomplished in several ways, but very few of them are efficient and easy. Fortunately, if you are a WordPress user, you are in luck! Remstate offers a free WordPress plugin called In Series that makes cross referencing posts in a series easy to accomplish.

Once you’ve uploaded and activated the plugin, the installation is complete! You will then see a field called In Series in your Dashboard’s Write panel. When writing the first post that belongs in a series, you will need to create a name for the series, then in any future installments of the series simply select it from the drop-down menu. If you’ve already written posts that belong in a series, you can go back and edit them and select the series in the drop-down menu. They will be added in the order that you’ve added them to the series, however, so you’ll want to add to the series in sequential order.

This plugin will not be necessary for all blogs, but I’ve found a lot of use for it on several blogs I run. It goes a long way towards retaining search engine traffic and increasing page views.

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

If you are a theme designer, or just enjoy customizing your existing WordPress theme, it can sometimes be a hassle digging around for the WordPress code you need. I’ve spent a lot of time on this site collecting various snippets of code since launch and decided that it would probably be more convenient and useful to people if I was to consolidate them all into one post for easy reference.

Here are the snippets of code I’ve managed to collect. If you have any WordPress code you’d like me to add, please leave a comment below!

Display Recent Posts

Here is the code you need to display the most recent 5 posts:

<?php query_posts('showposts=5'); ?>
<ul>
<?php while (have_posts()) : the_post(); ?>
<li><a href="<?php the_permalink() ?>"><?php the_title(); ?></a></li>
<?php endwhile;?>
</ul>

Display Recent Comments

<?php
global $wpdb;
$sql = "SELECT DISTINCT ID, post_title, post_password, comment_ID,
comment_post_ID, comment_author, comment_date_gmt, comment_approved,
comment_type,comment_author_url,
SUBSTRING(comment_content,1,30) AS com_excerpt
FROM $wpdb->comments
LEFT OUTER JOIN $wpdb->posts ON ($wpdb->comments.comment_post_ID =
$wpdb->posts.ID)
WHERE comment_approved = '1' AND comment_type = '' AND
post_password = ''
ORDER BY comment_date_gmt DESC
LIMIT 10";
$comments = $wpdb->get_results($sql);
$output = $pre_HTML;
$output .= "\n<ul>";
foreach ($comments as $comment) {
$output .= "\n<li>".strip_tags($comment->comment_author)
.":" . "<a href=\"" . get_permalink($comment->ID) .
"#comment-" . $comment->comment_ID . "\" title=\"on " .
$comment->post_title . "\">" . strip_tags($comment->com_excerpt)
."</a></li>";
}
$output .= "\n</ul>";
$output .= $post_HTML;
echo $output;?>

Display Top Comments

<?php $result = $wpdb->get_results("SELECT comment_count,ID,post_title FROM $wpdb->posts ORDER BY comment_count DESC LIMIT 0 , 10");
foreach ($result as $topten) {
$postid = $topten->ID;
$title = $topten->post_title;
$commentcount = $topten->comment_count;
if ($commentcount != 0) { ?>
<li><a href="<?php echo get_permalink($postid); ?>" title="<?php echo $title ?>"><?php echo $title ?></a></li>
<?php } } ?>

Display Categories

<h2>Categories</h2>
<ul>
<?php wp_list_cats('sort_column=name'); ?>
</ul>

Display Archives

<h2>Archives</h2>
<ul>
<?php wp_get_archives('type=monthly'); ?>
</ul>

Display a Pages Menu in your Sidebar

<h2>Pages</h2>
<ul>
<?php wp_list_pages('title_li='); ?>
</ul>

Display Gravatars (WordPress 2.5+ Only)

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

Display Blogroll Links

<ul>
<?php get_links_list(); ?>
</ul>

Display Admin Section

<ul>
<?php wp_register(); ?>
<li><?php wp_loginout(); ?></li>
<li><a href="http://www.wordpress.org/">WordPress</a></li>
<?php wp_meta(); ?>
<li><a href="http://validator.w3.org/check?uri=referer">XHTML</a></li>
</ul>

Display a Pages SubMenu in your Sidebar

This will display any subpages in your blog’s sidebar:
<?php$children = wp_list_pages('title_li=&child_of='.$post->ID.'&echo=0');if ($children) { ?><ul> <?php echo $children; ?>
</ul>
<?php } ?>

Display WordPress Tags

<?php the_tags(); ?>

Display WordPress Tags Cloud

<?php wp_tag_cloud('smallest=8&largest=36&'); ?>

Template Name

This allows you to use the WordPress page template to customize how a page is displayed:
<?php /* Template Name: Portfolio */ ?>

Dynamic Title Tags
<title><?phpif (is_home()) { echo bloginfo('name');
} elseif (is_404()) {
echo '404 Not Found';
} elseif (is_category()) {
echo 'Category:'; wp_title('');
} elseif (is_search()) {
echo 'Search Results';
} elseif ( is_day() || is_month() || is_year() ) {
echo 'Archives:'; wp_title('');
} else {
echo wp_title('');
}
?></title>

Display PHP on a Single Page

Allows you to display plugins and such on a single page (replace home with the page you want it to only appear on):
<?php if ( is_home() ) { include ('file.php'); } ?>

I’m expecting this list to grow over time as I come across more useful WordPress code and update the post.

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

As I’ve mentioned before, there are only a few select WordPress plugins that should be used by most WordPress blogs. Unless you are running a news site of some sort where your archived posts don’t hold any real value to search engine traffic, you should be using the Related Posts WordPress plugin to try to promote some of your older content.

The first thing you’ll notice after downloading this plugin, is that it is not overly easy to setup up.   In addition to the normal process of uploading it and activating it, you will more than likely need to make an update to one of your databases in order to function.  Here is what the author asks you to do:

ALTER TABLE `wp_posts` ADD FULLTEXT `post_related` (

`post_name` ,   `post_content` )

No idea how to create/alter a table?  No problem.  Here are the steps you’ll need to take to make the adjustment:

1) Backup your databases in case you have a problem.
2) Access your blog’s CPanel.
3) Click MySQL Databases.
4) Scroll down and click PHPMyAdmin.
5) If applicable, select the appropriate database in the menu on the right.
6) Scroll through your databases until you locate wp_posts.
7) In the Structure tab at the bottom, you should see some stuff that looks like this, but without the post_related field:

Post Related

We need to create the post_related field pictured above.

8) Where is says Create an index on 1 columns, click the Go button. You should now see this:

rp index

9) Under index name, type post_related.
10) In the Index type drop-down box, select FULLTEXT.
11) Click Go where it says Add to index 1 column(s).
12) In the first field, select post_date [postdate].
13) In the second field, select post_content [longtext].
14) Click Save.

Now you should see the post_related field pictured above!

Now you just need to tell the plugin where to display your related posts:

<?php if(function_exists('related_posts')) { related_posts(); } ?>

Now that its set up, you can then determine the number of posts you’d like to display from a Options panel under Plugins, and how you’d like to display them.

So, what exactly does this plugin do?  Well, the name of the plugin pretty much sums it up.  Using the keywords in your post titles, this plugin attempts to figure out the most relevant related posts to the post you just wrote, then them wherever you tell the plugin to display the related posts.  This is all done automatically, so you’ve got your plugin setup, there will not be any additional maintenance.

Any questions or thoughts?  Sound off in the comments below!

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

One of the best and most appealing parts of using WordPress is the various WordPress themes and WordPress plugins available. The plugins are easy to add, and the themes allow users to switch their blog’s theme with the click of a button.

If you have made a habit of regularly switching WordPress themes, you’ve probably noticed that there is a lot of stuff that needs to be done each time you make the switch. Here is a list of 8 reminders for you to follow each time you switch your WordPress theme:

  1. Transfer your metrics code - The most common thing people forget to do is transfer over their metrics scripts. These are usually found in the footer of your theme and can easily be transfered with a simple copy and paste.
  2. Transfer plugin calls - Remember all those plugins you installed that required calls to be placed in the theme? Those will each need to be transfered over to your new theme for your plugins to continue to function properly.
  3. Transfer sidebar stuff - If you are using widgets, this stuff will transfer over to new your widget-ready theme automatically. If you aren’t, you will need to transfer this stuff over manually.
  4. Verify your feeds work properly - Offering a valid feed to subscribers is crucial to a blogs success. You’ll want to make sure your feed is working properly, and if you use Feedburner, you will want to make sure your redirect is working properly.
  5. Update your advertising code - When you switch themes, you first need to transfer over your advertising code, then update the colors in the code to match your new theme.
  6. Test your theme for errors - Verify your menu is working properly, your tags, categories, and archives pages all work. You’ll also want to do a test search using the blog’s search engine.
  7. Test in all web browsers - You can either manually download and open your site in multiple web browsers (IE7, IE6, Firefox, and Opera), or try a service like Browsershots.
  8. Announce your theme change - Make a post that explains the change and ask readers to let you know if they encounter any problems. This way you can get feedback from people using a variety of browsers and resolutions.

That covers everything I typically do when setting up or switching WordPress themes. Miss any? Sound off in the comments below!

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

There are tons of great WordPress hacks out there, many of which I have or will be covering on this blog over the coming months. While researching a post I was working on, I happened to run across a very useful post at Tubetorial called 7 Essential WordPress Hacks that I thought I would share. Included in the post are a bunch of useful hacks for WordPress users that are done via videos.

Here is a list of the tubetorials that are covered in the post:

  1. How to Get More Search Engine Traffic With One Simple Tweak
  2. How to Make More Money With AdSense
  3. Feedvertising: Make Money With Your RSS Feed
  4. More Feedback, Less Spam: WordPress Contact Form Plugin
  5. How to Increase Comments and Page Views With One Quick and Easy Plugin
  6. How to Stop Comment Spam without Lifting a Finger
  7. Back Up Your Blog or Risk Losing It All

Enjoy!

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