File: /www/wwwroot/biographybirthday.com/wp-content/themes/bio/category.php
<?php get_header(); ?>
<?php
global $wpdb;
$year_week = date("YW");
$category_id = single_category_id();
$querystr = "
SELECT wp.* ,wv.count
FROM wp_posts wp
LEFT JOIN wp_post_views wv ON wv.id = wp.ID
LEFT JOIN wp_term_relationships ON (wp.ID = wp_term_relationships.object_id)
LEFT JOIN wp_term_taxonomy ON (wp_term_relationships.term_taxonomy_id = wp_term_taxonomy.term_taxonomy_id)
WHERE wp_term_taxonomy.term_id = '$category_id'
AND wv.type = 1
AND wv.period= '$year_week'
AND wp.post_status = 'publish'
AND wp.post_type = 'post'
AND wp.post_date < NOW()
ORDER BY wv.count DESC
";
$loop = $wpdb->get_results($querystr, OBJECT);
$title = get_the_category()[0]->cat_name;
hm_get_template_part('parts/content-popularity',array('loop'=>$loop, 'title'=>$title));
get_footer();
?>