popular posts functions

Creates data to get and set the most popular posts.

 '5',
        'post_status'     => 'publish',
		'orderby'         => 'meta_value_num',
		'meta_key'      => 'post_views_count',
		'order'        => 'DESC',
		'post_type'=>array(
			'post',
		)
    );
    $posts = get_posts($args);
    foreach ($posts as $post) {
		$post_id=$post->ID;
		$categories = get_the_category($post_id);
		$author = get_userdata($post->post_author);
		$i=0; 
		foreach ($categories as $category){
			if ($i==0){ 
				$cat_slug = $category->category_nicename; 
				$cat_title = $category->cat_name; 
			} 
			$i++;
		}
        $html .= '
			
  • '.$post->post_title.'
  • '; } return $html; } * add this at top of single posts page, inside the loop! * setPostViews(get_the_ID()); ?>