Tuesday, May 24, 2011

Display Twitter-like “time ago” on WP

Display Twitter-like “time ago” on your WordPress blog

Twitter have a built-in function that display time from now, like “3 days ago” or “more than a month ago”.If you want to do same with your WordPress post use the following function.

Paste the following into your functions.php file:






function post_time_ago( $type = 'post' ) {
    $d = 'comment' == $type ? 'get_comment_time' : 'get_post_time';
    return human_time_diff($d('U'), current_time('timestamp')) . " " . __('ago');
}

Now, you can use the following function in your theme files:
 echo post_time_ago();

Sunday, May 8, 2011

How to modify size of embedded videos

Modify size of embedded videos in wordpress

 In WordPress, it is easy to embed videos on the blog. But sometimes, dealing with  the video sizes is a bit painful. Here is a solution how you can adjust the size of any embedded video using a filter in wordpress

 Just  paste the following code on the functions.php file.

 function custom_embed_defaults($embed_size){
    $embed_size['width'] = 650; // Adjust values to your needs
    $embed_size['height'] = 550;

    return $embed_size;
 }

 add_filter('embed_defaults', 'custom_embed_defaults');

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