WordPress Popular Posts
WPP is showing all categories, not just one (6 posts)

  1. Nabha
    Posted 2 years ago #

    I'm using the short code and specifying cat="61" — but all the categories are showing. Any ideas what might fix this?

    I've verified that the categories are being seen by turning on stats_categories for a moment.

    Here's the complete shortcode:
    [wpp header="Most Popular" limit="4" range="monthly" post_type="page" cat="61" category_name="meditation" stats_comments=0]

    I'm using it on this page:

    A plugin, Post Tags and Categories for Pages, turned on categories for pages, which of course aren't normally available.

    I'd be happy to look into the plugin code and try to make a patch.


  2. Nabha
    Posted 2 years ago #

    Realized I didn't say: this is using WordPress 3.7.1 and the latest version of the plugin.

  3. Hector Cabrera
    Plugin Author

    Posted 2 years ago #

    Hey Nabha,

    Here's the problem: in WordPress, pages don't use categories. WPP doesn't filter pages by category. In fact, WPP ignores the cat attribute when post_type is page.

    Also, the category_name attribute doesn't exist :P

  4. Nabha
    Posted 2 years ago #

    Aha, but pages *can* have categories, as mine do -- it's just not the default. Would you be willing to take a look at a patch for this if I created one?

    Ah -- category_name is in WP_Query, and for some reason I thought WPP supported WP_Query arguments, but I must have dreamed that up.

  5. Nabha
    Posted 2 years ago #

    Oh, it turns out that the patch is trivial, thanks to your coding.

    You just comment out lines 874 and 875:

    //if ( strtolower($instance['post_type']) == 'page' )
    //	$join_cats = false;
  6. Nabha
    Posted 2 years ago #

    Just thinking about this more... it would be better to join the categories table for pages only if that use has been requested.

    So, if cats is set to any value and page is one of the requested post types... then $join_cats = true.

    What do you think? Still happy to create a patch.

Topic Closed

This topic has been closed to new replies.

About this Plugin

  • WordPress Popular Posts
  • Frequently Asked Questions
  • Support Threads
  • Reviews

About this Topic


No tags yet.