WordPress QuickTips

Here’s a little snippet of code that could come in handy: a total post count for a blog. Put this in your page to display the total amount of posts you’ve made:

<php the_author_posts(); ?>

This might come in handy when you’d like to display the total number of tutorials on a tutorial blog, sites indexed in a site gallery, etc.

Here’s another WordPress QuickTip that will save you some extra keystrokes. Whenever you want to link to an image, place in your site, etc, this little PHP snippet will save you the hassle of typing in the web address:

<?php echo(get_option('siteurl')); ?>

This will display the complete URL (http://www.yoursite.com) wherever you put this tag.

Modifying Individual Posts In The Loop

When coding themes, clients frequetly request things like Google ads being displayed after post #2, the top post having a differently colored background, only displaying the title for a few posts - stuff like that. You can’t do any of this inside a single Loop, so here’s how to use multiple loops to display lists of posts differently.

Read more…

The easiest way to display ‘Home’ as a navigation link, Period.

Here is the easiest way to display a homepage link in the navigation bar of your WordPress site. I can guarantee that you won’t find an easier way out there.

The code:

<ul>
<li><?php if ( is_home() ) { ?> class="current_page_item"<? } ?></li>
<?php wp_list_pages('title_li='); ?>
</ul>

It’s pretty obvious how this code works. If the current page is the blog’s homepage, then it’ll add a special class to the list item to mark it as the current page. If it isn’t, the navigation button displays normally.

That’s it. No extra pages, no special configuration. The easiest way to display ‘Home‘ as a navigation link, period.