Need Help with the function of a WP widget!!

0 replies
hey guys i recently ordered this gig on fiverr asking for my trending widgets to show the most viewed posts over a 7 days period sorting from most viewed to least viewed, however the programmer did not quite do what i asked. Instead the person is only making the widgets show posts that are less than seven day.

See the widgets in my site here: Yardhype

This was the original code:
<ul>



<?php query_posts('showposts=5 & category_name=videos'); ?>







<?php while (have_posts()) : the_post(); ?>



<li>



<div class="boxtitle"><a href="<?php the_permalink(); ?>"><p><?php limit_title($post->post_title, 40); ?></p></a></div>



<div class="boxauthor"><p><?php the_author(); ?>&nbsp;&nbsp;<span class="hoursago"><?php the_time(); ?><p></div>



</li>



<?php endwhile;?>



<?php wp_reset_query(); ?>



</ul>



</div>
how can i fix this code to make the widget display what i want?
which is the most viewed pots.

At the moment the fiverr gig result: code below is causing posts that are older than 7 days to disappear from the widget



fiverr gig result:


<?php


//------ Added by Ganesh -----------------
function filter_where($where = '')
{
//posts in the last 7 days
$where .= " AND post_date > '" . date('Y-m-d', strtotime('-7 days')) . "'";
return $where;
}
add_filter('posts_where', 'filter_where');
//------ End by Ganesh -----------------
query_posts('showposts=5 & category_name=videos');

?>







<?php while (have_posts()) : the_post(); ?>



<li>



<div class="boxtitle"><a href="<?php the_permalink(); ?>"><p><?php limit_title($post->post_title, 40); ?></p></a></div>



<div class="boxauthor"><p><?php the_author(); ?>&nbsp;&nbsp;<span class="hoursago"><?php the_time(); ?><p></div>



</li>



<?php endwhile;?>



<?php wp_reset_query(); ?>



</ul>



</div>



I am willing to pay if its not a simple fix.

Thank You
#function #widget

Trending Topics