Changing comment_count to views

Yes, you have to calculate page views. Do not use plugin as it needs a small piece of code.

Below code will increase pageviews and will store in post meta. Use this code in single.php or loop-common.


if( is_single() ) {

/* Increase post view count by 1 */
        $post_view_count = get_post_meta($post_id, 'view_count', true);

        if( $post_view_count=='' ) {                
                update_post_meta($post_id, 'view_count', 1);                
        }
        else{
                $post_view_count = intval($post_view_count);
                ++$post_view_count;
                update_post_meta($post_id, 'view_count', $post_view_count);
        }
}

Reteriving posts based on views


$popular_query = array( 'post_type' => 'post', 'posts_per_page' => 5, 'order' => 'DESC', 'orderby' => 'meta_value_num', 'meta_key' => 'view_count');

UPDATE

paste your code (as it is, no changing of post_id) like this in single.php.



function custom_categories_listing()
  {
    $categories = get_the_category($post->ID);
    if(!empty($categories)){
        foreach ($categories as $cat) {
            $html="";
            $html .= '
  • cat_ID) . '" class="odd"'; $html .= 'title="' . $cat->cat_name . '">' . $cat->cat_name . '
  • '; echo $html; } } } /* Increase post view count by 1 */ $post_id = get_the_ID(); $post_view_count = get_post_meta($post_id, 'view_count', true); if( $post_view_count=='' ) { update_post_meta($post_id, 'view_count', 1); } else{ $post_view_count = intval($post_view_count); ++$post_view_count; update_post_meta($post_id, 'view_count', $post_view_count); } ?>

    Below custom_categories_listing function and above breadcrumb.

    Now i think you can figure it out.

    Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)