Hello guys,
I have the same problem that perfectlover had in the first place. I try to display the most viewed posts and the least viewed posts of a category on the category's template (category-N.php).
I tried this:
<?php if (function_exists('get_most_viewed_category') && intval(get_query_var("cat")) > 0): ?>
<ul>
<?php get_most_viewed_category(get_query_var("cat"),'both',10); ?>
</ul>
<?php endif; ?>
but it returns "N/A".
After reading Lester Chan's forum (this topic in particular), I came up with this:
<?php
query_posts('v_sortby=views&v_orderby=asc');
$recent_posts = new WP_Query("cat=3&showposts=3&post_status=publish");
while ($recent_posts->have_posts()):
$recent_posts->the_post();?>
<li><a href="<?php the_permalink() ?>" title="<?php the_title(); ?>"><?php the_title(); ?></a><span>(<?php the_views() ?> fois)</span></li>
<?php
endwhile;
wp_reset_query();
?>
Which works fine to display the least viewed posts.
However, when I replace "asc" by "desc" in the first query line, I get the exact same list, that is to say a list of the LEAST viewed posts, and not the most viewed ones.
Any idea why sorting posts by "desc" doesn't work?
The code used to work, though, with 2.7.2. I upgraded to 2.8.2 a few days ago, and it seems the problem appeared at that moment.
Thanks a lot for your help!