WordPress.org

Ready to get started?Download WordPress

Forums

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

  1. Nabha
    Member
    Posted 10 months 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:
    http://www.ananda.org/meditation/

    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.

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

  2. Nabha
    Member
    Posted 10 months ago #

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

  3. Héctor Cabrera
    Member
    Plugin Author

    Posted 10 months 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
    Member
    Posted 10 months 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
    Member
    Posted 10 months 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
    Member
    Posted 10 months 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.

Reply

You must log in to post.

About this Plugin

About this Topic

Tags

No tags yet.