I have this question unanswered since I started learning. I have search for so long but non seems to work. I know about wordpress popular post plugins but I want to do this without plugins on a custom theme am building. Please I have seen so many codes but they did not work as expected. Anyone has something that can help?
Show us what code you have tried, and give us an idea of how it didn’t produce what you needed.
alright. Currently I am trying it on tophits.ng but here is the code which outputs popular post but not one week post or even one month which i can go with.
<?php $paged = (get_query_var('page')) ? get_query_var('page') : 1; query_posts('meta_key=post_views_count&posts_per_page=20&orderby=meta_value_num& order=DESC'); if (have_posts()) : while (have_posts()) : the_post(); ?> <li class="category_list"> <div class="cat-post-thumb" <?php $thumb = wp_get_attachment_image_src( get_post_thumbnail_id($post->ID), 'full' );?> style="background-image: url('<?php echo $thumb['0'];?>')"> <a class="the-post-link" href="<?php the_title(); ?><?php the_permalink(); ?>"></a> </div> <div class='cat-post-text'> <a href="<?php the_permalink(); ?>"><?php the_title(); ?></a> </li> <?php endwhile; endif; wp_reset_query(); ?>
This gets post that are too old and it doesnt give any pagination too.
I want to make it get only most viewed post in one week. Thanks very much for your help. I really appreciate.