How to Stop Self Pings

Pings are a lot helpful if something relative links to you but what if you start pinging yourself; isn’t it a bit annoying? It feels so weird to ping oneself, why would anybody wish to ping his/her own previously published posts? – Especially when there are so many better hyper-linking options available (think about ‘smart links’, ‘related posts’, etc.).

If you have the pinging option enabled, WordPress generates self pings each time you link to your own posts. If you are you just tired of the self pings and want to opt out of it, here is the solution.

The easiest way, of course, is to install any of the available plugins for this, like No Self Pings. But if you do not wish to install a plugin and are game enough to touch your theme files, here is how you go about.

1. Log in to your WordPress admin panel

2. Navigate to Appearance >> Editor >> Functions.php

3. Start editing it, put the below given code in the functions.php file you are editing

//remove self pings
function no_self_ping( &$links ) {
$home = get_option( ‘home’ );
foreach ( $links as $l => $link )
if ( 0 === strpos( $link, $home ) )
unset($links[$l]);
}
add_action( ‘pre_ping’, ‘no_self_ping’ );

Once you have this code in your functions.php file, save it by clicking on the Update File option. Great you are done!

How to Add Author Bio on Each Blog Post

Many of the themes today come with author bio pre-installed but some do not; and in that case you can get one either by installing a plugin or by hard coding the author bio section in your theme’s single post page. Most of the bloggers go for the plugin option since it’s the easier one. But if you think you already have a lot of plugins and do not want to add one more to the list, here is how to get it done through coding. Ah it too is not that difficult either.

So, to have a small author bio section just below your post :

1. Log in to your WordPress admin panel

2. Navigate To Appearance >> Editor

3. The page which appears before you once you navigate to above location is the CSS file of your site; or in simple words, it’s the file where your site’s design lies. Scroll to the last line of the page hit enter to create a space and then put this small piece of code there (in your Style.css file):

#authorbox{
background:#EFEFEF;
border:2px solid #CECFD0;
width:538px;
margin:0 auto;
margin-top: 5px;
margin-bottom:10px;
overflow:hidden;
}
#authorbox h4{
font-size:16px;
color:#191919;
margin:0;
padding:5px 10px 5px 10px;
}
.authortext{
padding-left:100px;
}
#authorbox img{
margin:0;
padding:10px;
float:left;
}
#authorbox p{
color:#191919;
margin:0;
padding:0px 10px 10px 10px;
}
#authorbox h4 > a{
text-decoration:none;
}
#authorbox p{
color:#191919;
}

4. Once you are done with pasting the above code in the Style.css file, search for the page called single.php. Open it and get to the desired location where you want the author bio to appear and then paste the below given code there:

<div id=”authorbox”>
<?php if (function_exists(‘get_avatar’)) { echo get_avatar( get_the_author_email(), ’80’ ); }?>
<div class=”authortext”>
<h4>About <a href=”<?php the_author_url(); ?>”>
<?php the_author_firstname(); ?> <?php the_author_lastname(); ?></a></h4>
<p><?php the_author_description(); ?>. <?php the_author_firstname(); ?> has written <strong><?php the_author_posts(); ?></strong> awesome articles for <?php bloginfo(‘name’); ?>, See all the posts written by <?php the_author_posts_link(); ?>.</p>
</div>
</div>

Note : If you are not able to decide where to place the code, then place the above code just below the following code in your single.php file (This will make your author bio appear just below your post):

<div>
<?php if (function_exists(‘digg_this_button’)) { ?><div style=”float: left;”><?php digg_this_button(); ?></div><?php } ?>
<?php the_content(‘<span>Continue Reading</span>’); ?>
<!– google_ad_section_end –>
<?php wp_link_pages(‘before=<div id=”page-links”>&after=</div>’); ?>
</div>

Now, save the changes to the single.php file and clear your browser cache; its time for a site preview. Go to a post and you should find your author bio appearing there.

Adding Social Media Share Buttons Beside Post Excerpts

Social media has gained significant prominence as a source of traffic. If you look at some of the popular blogs out there, you will find that most of them have a LIKE button and a RETWEET button just beside the post excerpt. If you have been wondering how to do that, here is how you can give your visitors an option to share the content from the homepage itself.

To add a Twitter RETWEET button and a Facebook LIKE button beside the post excerpt on the home page:

1. Log in to your WordPress Admin Panel

2. Navigate to Appearance >> Editor >> Index.php

3. Search for this piece of code :

<div class=”entry”>

4. Once you find it paste the below given code right under it :

<div align=”right”><div id=’twittley_button’ style=’float:right;margin-left:10px;’>
<div id=”fblike”>
<script src=”http://connect.facebook.net/en_US/all.js#xfbml=1″></script>
<fb:like href=”<?php echo get_permalink($postid); ?>” layout=”box_count” show_faces=”true” font=””></fb:like></div><br />
<a href=”http://twitter.com/share” class=”twitter-share-button” data-url=”<?php echo get_permalink($postid); ?>” data-text=”
<?php the_title(); ?>” data-count=”vertical” data-via=”YourTwitterID”>Tweet</a>
<script type=”text/javascript” src=”http://platform.twitter.com/widgets.js”></script>
</div></div>

Note : Don’t forget to change the via – “YourTwitterID” to your own twitter username.

Once done, save the file by clicking on the update file button. That’s it. You have successfully integrated the social sharing buttons on the homepage beside each of the post excerpts.