All Good Things Must Come To An End

As you all know, I have been doing WordPress plugins and supporting it for the past 6 years. These 6 years of my life, I have been through my polytechnic education, my national service as well as my university education.

I just graduated from university in December 2009 and have been looking for full-time jobs. I am offered a full-time job and will be starting work on 1st February 2010.

I regret to say that I am NOT ABLE to provide support for my plugins anymore due to my full-time job commitment. I will leave this forum open and let the community help one another.

However, I WILL still update my plugins whenever I can and you still can report bugs to me via email and I will try to fix it.


Author Topic: Most viewed per category  (Read 2008 times)

0 Members and 1 Guest are viewing this topic.

Offline shobgupta

  • Newbie
  • *
  • Posts: 5
    • View Profile
Most viewed per category
« on: 30 January 2009, 10:50 »
I am using most viewed post per category code to show most viewed posts from category. But it can only show posts if I defined category ID. Is thee any way it takes category ID itself and shows posts from that categroy. I am planning to use in single page.

Offline GaMerZ

  • lesterchan.net
  • Administrator
  • *****
  • Posts: 11,511
    • View Profile
  • WordPress Version: WordPress 2.9.x
  • Theme Name: lesterchan.net v3.4
Re: Most viewed per category
« Reply #1 on: 30 January 2009, 11:37 »
Try using
Code: [Select]
get_query_var("cat") to get the current category id and pass it to the PHP function.

++ lesterchan.net - Lester Chan's Website

I regret to say that I am not able to provide support for my plugins anymore due to my full-time job commitment. I will leave this forum open and let the community help one another.

Offline shobgupta

  • Newbie
  • *
  • Posts: 5
    • View Profile
Re: Most viewed per category
« Reply #2 on: 30 January 2009, 19:11 »
I am using following code...does not work.
<?php $cat = get_the_category(); $cat = $cat[0]; ?>
<?php
query_posts(array('cat'=>$cat->cat_ID,'showposts'=>'5',));?>
<?php get_most_viewed_category(); ?>
<?php endwhile; ?>
« Last Edit: 30 January 2009, 19:42 by shobgupta »

Offline GaMerZ

  • lesterchan.net
  • Administrator
  • *****
  • Posts: 11,511
    • View Profile
  • WordPress Version: WordPress 2.9.x
  • Theme Name: lesterchan.net v3.4
Re: Most viewed per category
« Reply #3 on: 31 January 2009, 02:54 »
Did you even try my code? Just to let you know modification of my plugin is not within my support scope.

++ lesterchan.net - Lester Chan's Website

I regret to say that I am not able to provide support for my plugins anymore due to my full-time job commitment. I will leave this forum open and let the community help one another.

Offline shobgupta

  • Newbie
  • *
  • Posts: 5
    • View Profile
Re: Most viewed per category
« Reply #4 on: 31 January 2009, 10:16 »
Hi Lester,
I tried your code as following
<?php if (function_exists('get_most_viewed_category')): ?>
   <ul>
      <?php get_most_viewed_category('get_query_var("cat")','both',10); ?>
   </ul>
<?php endif; ?>

I got N/A as output. I sent you a PM regarding this modification.
Thanks
shob

Offline GaMerZ

  • lesterchan.net
  • Administrator
  • *****
  • Posts: 11,511
    • View Profile
  • WordPress Version: WordPress 2.9.x
  • Theme Name: lesterchan.net v3.4
Re: Most viewed per category
« Reply #5 on: 31 January 2009, 12:16 »
Remove the single quotes surronding the get_query_var

Code: [Select]
<?php if (function_exists('get_most_viewed_category')): ?>
   <ul>
      <?php get_most_viewed_category(get_query_var("cat"),'both',10); ?>
   </ul>
<?php endif; ?>
« Last Edit: 31 January 2009, 15:35 by GaMerZ »

++ lesterchan.net - Lester Chan's Website

I regret to say that I am not able to provide support for my plugins anymore due to my full-time job commitment. I will leave this forum open and let the community help one another.

Offline shobgupta

  • Newbie
  • *
  • Posts: 5
    • View Profile
Re: Most viewed per category
« Reply #6 on: 31 January 2009, 18:51 »
Lester, I appreciate very much for providing out of scope help. Sadly, this code is still giving me N/A., I have given up now as I don't know about PHP.

Probably, you can include this as a new feature in a future version of this plugin. I am a confident many people wanted this.

Thanks again and Have a nice weekend.

Offline GaMerZ

  • lesterchan.net
  • Administrator
  • *****
  • Posts: 11,511
    • View Profile
  • WordPress Version: WordPress 2.9.x
  • Theme Name: lesterchan.net v3.4
Re: Most viewed per category
« Reply #7 on: 01 February 2009, 03:15 »
Let me get back to you on this one after I tried it, I don't think it is difficult.

++ lesterchan.net - Lester Chan's Website

I regret to say that I am not able to provide support for my plugins anymore due to my full-time job commitment. I will leave this forum open and let the community help one another.

Offline GaMerZ

  • lesterchan.net
  • Administrator
  • *****
  • Posts: 11,511
    • View Profile
  • WordPress Version: WordPress 2.9.x
  • Theme Name: lesterchan.net v3.4
Re: Most viewed per category
« Reply #8 on: 01 February 2009, 08:01 »
I tested with this code:
Code: [Select]
<?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; ?>

And it works on the default theme (archive.php). You cannot put it in anywhere except the archive.php because that is the only page where the category information get retrieved.

++ lesterchan.net - Lester Chan's Website

I regret to say that I am not able to provide support for my plugins anymore due to my full-time job commitment. I will leave this forum open and let the community help one another.

Offline shobgupta

  • Newbie
  • *
  • Posts: 5
    • View Profile
Re: Most viewed per category
« Reply #9 on: 01 February 2009, 12:02 »
Thanks a lot. It is working nicely on archive.php.