Number your wordpress comments
February 3, 2009
Do your blog posts receive lots of comments? If yes, it can be really useful for both you and your readers to number it. Here’s how to do it easily and efficiently. Open comments.php and find the following line: <?php foreach ($comments as $comment) : ?> Just below this line, initialize a counter variable: <?php $i = 0; ?> Just after this line, increment the counter: <?php $i++; ?> Now, you just have to echo the $i variable to get the number of the current comment. Paste this code anywhere on your comments... [Read the full story]
Redifine wordpress title tag with a custom field
February 1, 2009
Open your header.php file for edition. find the <title> tag, and replace it by the following code: <title> <?php if (is_home () ) { bloginfo('name'); } elseif ( is_category() ) { single_cat_title(); echo ' - ' ; bloginfo('name'); } elseif (is_single() ) { $customField = get_post_custom_values("title"); if (isset($customField[0])) { echo $customField[0]; } else { single_post_title(); } } elseif (is_page() ) { bloginfo(’name’); echo ‘: ‘; single_post_title(); }... [Read the full story]
Display your current mood on your wordpress posts
February 1, 2009
Open your single.php file (You can also modify your index.php file) and paste the following code anywhere within the loop: $customField = get_post_custom_values("mood"); if (isset($customField[0])) { echo “Mood: “.$customField[0]; Save the file. Now when you’ll write a new post, just create a custom field named mood and type your current mood as a value. Read More →
Display a text or code only if more than X posts are published
February 1, 2009
To achieve this recipe, we’re going to use a cool new function, introduced in WordPress 2.7, and called wp_count_posts(). Paste the following code anywhere on your template: <?php $count_posts = wp_count_posts(); if ($count_posts->publish > 10) { //Your code to be displayed only if more than ten posts have been published } ?> Note that you’ll need to replace 10 by the number of posts which are displayed at the same time on your homepage. Read More →




















