WordPress.org

Ready to get started?Download WordPress

Forums

WordPress Popular Posts
Category Specific? (12 posts)

  1. rhythmdoctor
    Member
    Posted 3 years ago #

    Is there any way to configure this plugin to show the most popular posts on category pages that are specific to those given categories? I would LOVE that and happy to help in any way I can. Thanks in advance.

    http://wordpress.org/extend/plugins/wordpress-popular-posts/

  2. WPElliott
    Member
    Posted 3 years ago #

    I agree, this would be most helpful.

  3. rhythmdoctor
    Member
    Posted 3 years ago #

    PLEASEEE :)

  4. kaynenh
    Member
    Posted 3 years ago #

    Looking at the code in 'wordpress-popular-posts.php', I was able to do this by adding an extra category string to the $mostpopular string. I based it off of ramdev's exclusion code and added it immediately afterward. Here's what you are looking for, I believe:

    [Code moderated as per the Forum Rules. Please use the pastebin]

    Let me know if that makes sense!

  5. WPElliott
    Member
    Posted 3 years ago #

    Sorry, I could not get that to work. Seems like there is a lot more to be done than just your code snippet.

  6. kaynenh
    Member
    Posted 3 years ago #

    @WPElliot

    It seems to be working on my end... does it just break the plugin for you or does it appear to not do anything at all? Are you using exclusion categories because I haven't tested that on my end. I modified my removed code from above and added something that tests which category you are currently within... could you try this and let me know if it correctly displays the current category?

    (Note that I changed the line that says $content = '')

    http://pastebin.com/ThqA5PB7

  7. WPElliott
    Member
    Posted 3 years ago #

    I need to add this functionality as I use the other wpp tags for other pages like:

    [wpp range=all limit=20 stats_views=1 order_by=views pages=0 wpp_start=<ul> wpp_end=</ul>]

    So, in addition to using the shortcode above, I would like to use one like:

    [wpp range=all limit=20 stats_views=1 order_by=views pages=0 include-cats=65 wpp_start=<ul> wpp_end=</ul>]

    which means I need a new attribute called include-cats.

  8. kaynenh
    Member
    Posted 3 years ago #

    Gotcha! I was doing the above based on the premise you were using a widget and that widget was applied site-wide...

    In any case, I've done what you asked, using the shortcode attribute "cats_to_include". The attached code also includes a "Restrict posts to categories" checkbox in the widget. I've simply added my entire rework of wordpress-popular-posts.php because there were about six different areas I had to add code. I've included "kaynenh" in the comments of every edit so you can search and find the changes.

    http://pastebin.com/zZ0Lu520

  9. WPElliott
    Member
    Posted 3 years ago #

    You are 'da man! I replaced your code with the code in the WPP .php file and voila, I now have a capability to show popular posts based on included categories.

    Thank you very much!
    Bill

  10. rhythmdoctor
    Member
    Posted 3 years ago #

    Kaynenh,

    Do we just need to replace the entire code in wpp php file to what you have at that link? Anyone know if the plugin developer will actually implement this moving forward (IE - should I just wait for an updated version)?

    Thanks in advance.

  11. WPElliott
    Member
    Posted 3 years ago #

    Replace all of the code with the code at the link above.

    BTW, the original code is causing significant throttling by my host. The new code doubled the amount of throttling. So, if there is an issue with the way popular posts is being implemented, then the problem has been repeated. I have a programmer friend looking at the code for me to see if he can tell what is causing the problem. Will let you know if we find a solution.

    Please check throttling on you site. Try deactivating the WP-popular-posts plugin for a day and compare your throttling values. Then, see if the new code makes the throttling problem double. If so, we definitely need to get this fixed.

  12. rhythmdoctor
    Member
    Posted 3 years ago #

    @wpelliott - any further insight on your end with regard to the throttling... And (cause Im more of a marketer, just enough IT knowledge to be dangerous :) how would someone see this? Is this CPU usage that I would see on the server or slow down within the wp-admin console? Perhaps you've already determined that it's ok now or you've been able to fix it? I love your thoughts as I have a pretty heavy volume/traffic to my site and quite a few plugins so... Im afraid to try it because if the site goes down, so does the income :) Thanks in advance..

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic