socca1157
Forum Replies Created
Viewing 1 replies (of 1 total)
-
Forum: Plugins
In reply to: [WP Popular Posts] How do I "Prettify" the {date} output?Thanks for the link to the example, it was perfect!
Here’s what I came up with if anyone else wants to use it.
/** * Prettify the date for populer posts */ function my_custom_single_popular_post( $post_html, $p, $instance ){ $category = get_the_category( $p->id ); $cat_name=$category[0]->cat_name; $days = round((date('U') - strtotime($p->date)) / (60*60*24)); if ($days==0) {$wpp_time="Posted Today";} elseif ($days==1) {$wpp_time="Posted Yesterday";} else {$wpp_time="Posted ".$days." days ago";} $output = '<li> <div class="publish_time">'.$wpp_time.'</div> <a href="' . get_the_permalink($p->id) . '" target="_blank" class="wpp-post-title" title="' . esc_attr($p->title) . '"> <img class="wpp-thumbnail" src="'.wp_get_attachment_url(get_post_thumbnail_id($p->id)).'" title="' . esc_attr($p->title) . '" alt="' . esc_attr($p->title) . '"></a> <a href="' . get_home_url(). '/'.strtolower($cat_name).'/" target="_blank" class="wpp-post-category">' . $cat_name . '</a> <a href="' . get_the_permalink($p->id) . '" target="_blank" class="wpp-post-title" title="' . esc_attr($p->title) . '">' . $p->title . '</a> </li>'; return $output; } add_filter( 'wpp_post', 'my_custom_single_popular_post', 10, 3 );
Viewing 1 replies (of 1 total)