Example #1
0
/**
 * Get post views by 'WP Postviews' plugin
 */
function dp_get_post_views($post_id = '')
{
    global $post;
    if (!$post_id) {
        $post_id = $post->ID;
    }
    $views = get_post_meta($post_id, 'views', true);
    $views = absint($views);
    $views = short_number($views);
    return $views;
}
Example #2
0
/**
 * Get post likes
 */
function dp_get_post_likes($post_id = '')
{
    global $post;
    if (!$post_id) {
        $post_id = $post->ID;
    }
    $likes = get_post_meta($post_id, 'likes', true);
    if ($likes == '') {
        add_post_meta($post_id, 'likes', 0, true);
    }
    $likes = absint($likes);
    $likes = short_number($likes);
    return $likes;
}