Avoid duplicate content in WordPress blog

January 19, 2009

Duplicate content is often a problem with WordPress blog, and as you probably know it, it can hurt your blog SEO. Here is a small code to insert on your header.php file, to get rid of duplicate content in your WordPress blog. Simply paste theses line between the <head> and </head> tags in your header.php file. <?php if((is_home() && ($paged < 2 )) || is_single() || is_page() || is_category()){ echo '<meta name="robots" content="index,follow" />'; } else { echo '<meta name="robots"... [Read the full story]

Use a custom blurb when listing wordpress pages

January 18, 2009

How to get a list of pages along with a custom key from each page, used to create a description? The first thing to do is to paste the following code where you want your pages to be listed. It can be your sidebar, or a page template, for exemple. <?php $pages = get_pages(); foreach($pages as $page) { $custom_blurb = get_post_meta($page->ID, 'custom_blurb', true); echo "<h3><a href=\"".get_page_link($page->ID)."\">$page->post_title</a></h3>"; echo $custom_blurb; } ?> Once... [Read the full story]

Add author’s gravatar in wordpress posts

January 18, 2009

What about displaying the author picture in your posts? Sure, you can use a well known hack to display a picture located in your theme directory, but what about using Gravatar? In this article, we’ll show you how you can easily get the post author gravatar and display it. To achieve this recipe, simply paste the following code on your single.php file, where you want the gravatar to be displayed: <?php $author_email = get_the_author_email(); echo get_avatar($author_email, '96'); ?>  Read More →

Link to some external resource in wordpress post title

January 16, 2009

Sometimes, you may want to publish a post which only consist of an url pointing to some external resource. As there’s no built-in function to do that in wordpress, let’s create our own.   The first thing to do is to open your functions.php file and paste the following code:   function print_post_title() { global $post; $thePostID = $post->ID; $post_id = get_post($thePostID); $title = $post_id->post_title; $perm = get_permalink($post_id); $post_keys = array(); $post_val = array(); $post_keys... [Read the full story]

Get thumbnails from specific wordpress posts

January 16, 2009

Nowadays, many WordPress users are using a custom field to illustrate their posts with a thumbnails, then how to get the thumbnails related to a specific kind of posts, most commented? To get a list of thumbnails from the most commented post, we have to use a SQL request and some PHP. Paste the following code anywhere on your theme, where you’d like the thumbnails to be displayed. Each thumbnail contains a link to read the associated post. <ul> <?php //The name of custom field you'd like to get, don't forget to... [Read the full story]