WordPress.org

Support

Support » Plugins and Hacks » WPP is showing all categories, not just one

WPP is showing all categories, not just one

  • 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/

Viewing 5 replies - 1 through 5 (of 5 total)
  • Realized I didn’t say: this is using WordPress 3.7.1 and the latest version of the plugin.

    Plugin Author Hector Cabrera

    @hcabrera

    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 😛

    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.

    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;

    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.

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘WPP is showing all categories, not just one’ is closed to new replies.