Tuesday, November 27, 2012

How to create a Pinterest "pin it" button for your WordPress blog

How to create a Pinterest "pin it" button for your WordPress blog

Just paste the following code where you like the "Pin It" button to be displayed. But remeber that this code must be inserted within the loop.

<a href="http://pinterest.com/pin/create/button/?url=<?php the_permalink(); ?>&media=<?php $thumb = wp_get_attachment_image_src( get_post_thumbnail_id($post->ID), 'thumbnail' ); echo $thumb['0']; ?>&description=<?php the_title(); ?>" class="pin-it-button" count-layout="horizontal">Pin It</a>

Now footer.php file and add the pinterest JavaScript code:

<script type="text/javascript" src="http://assets.pinterest.com/js/pinit.js"></script>

Thursday, November 22, 2012

Automatic “Nofollow” for external links in post content of wordpress

Automatic “Nofollow” for external links in post content of wordpress

WordPress hack: Automatic “Nofollow” for external links in post content of wordpress

WordPress does not automatically by default add a rel=”nofollow” attribute to its external links within the post content. But If you want to add this attribute, the following solution help you to force WordPress to add the rel=”nofollow” attribute to every external link.

To make this work just Paste the following code in the functions.php file. Now save the file, you can see that all external links in your post content will be changed to nofollow.

add_filter('the_content', 'auto_nofollow');

function auto_nofollow($content) {
    //return stripslashes(wp_rel_nofollow($content));

    return preg_replace_callback('/<a>]+/', 'auto_nofollow_callback', $content);
}

function auto_nofollow_callback($matches) {
    $link = $matches[0];
    $site_link = get_bloginfo('url');

    if (strpos($link, 'rel') === false) {
        $link = preg_replace("%(href=S(?!$site_link))%i", 'rel="nofollow" $1', $link);
    } elseif (preg_match("%href=S(?!$site_link)%i", $link)) {
        $link = preg_replace('/rel=S(?!nofollow)S*/i', 'rel="nofollow"', $link);
    }
    return $link;
}

How to remove WordPress version number from pages and feeds

How to remove WordPress version number from pages and feeds

WordPress always publicly display wordpress version number in RSS and Atom feeds by default. With the following solution we can remove those wordpress version number from all our blog feeds.

You need to just use this code in functions.php file

add_filter('the_generator', 'digwp_complete_version_removal');
function digwp_complete_version_removal() {
    return '';
}

I just got my #domain @BigRock. Get upto 25% off with my personalized coupon link Get upto 25% off