Use two different WordPress loops
October 27, 2008
Maybe you wants to get the most recent posts first, and later create a new loops getting the 5 next posts, excluding the most recent post. To achieve what you wants to do, we have to use the query_posts() function with the showposts and offset parameters. The first loop: query_posts('showposts=1'); // First loop, we only get the most recent post if (have_posts()) : while (have_posts()) : the_post(); ?> // WordPress loop endwhile; endif; ?> The second loop: query_posts('showposts=5&offset=1');... [Read the full story]
Add meta description to your wordpress theme
October 27, 2008
Open your header.php file. Paste the following code anywhere within the <head> and </head> tags: <?php if ( (is_home()) || (is_front_page()) ) { ?> <meta name="description" content="Blog description goes here" /> <?php } elseif (is_single()) { ?> <meta name="description" content="<?php the_excerpt();?>"/> <?php } ?> Good job! Your theme now have meta description on the homepage as well as single posts. Also, we should create another conditionnal structure to handle categories. Read More →
Limit the size of the post excerpt without using a plugin
October 26, 2008
Edit your single.php file and replace the the_excerpt() function by the following code: <?php $len = 50; //Number of words to display in excerpt $newExcerpt = substr($post->post_excerpt, 0, $len); //truncate excerpt according to $len if(strlen($newExcerpt) < strlen($post->post_excerpt)) { $newExcerpt = $newExcerpt."[...]“; } echo “<p>”.$newExcerpt.”</p>”; //finally display excerpt ?> Let’s have a look at the code: First, we define the desired number of words... [Read the full story]
Replace WordPress default smilies
October 25, 2008
Wanna be a bit more original? So why not replacing WordPress default smilies on your blog? Here’s about how to do it: First, find some smilies packs that you can download and use on your WordPress blog. Then chose one and uncompressed it, use to favorite FTP client and navigate throught the /wp-includes/images/smilies/ directory. Upload your new smilies there. This will replace original WordPress smilies, so make sure to backup before, in case you’d like to switch back to the default smilies pack later. Read More →
Exclude categories from your rss feed
October 25, 2008
Depending to your blog structure, it may be interesting to exclude some categories from your rss feeds. Before starting to code, you’ll have to know the numeric ID of the categories you want to exclude. Once you have the ID of the categories you want to exclude from your rss feed, open the functions.php file from your theme. If your theme doesn’t have a functions.php file, create one. Paste the following code in it: function myFilter($query) { if ($query->is_feed) { $query->set('cat','-5'); //Don't... [Read the full story]



















