WordPress.org

Ready to get started?Download WordPress

Forums

PHP plugin mod. (5 posts)

  1. Kiddeath91
    Member
    Posted 8 years ago #

    Trying to modify the WP plugin WordPress Category Map. I contacted the original author, but he hasn't gotten back to me.

    As the plugin currently operates, it will show a tag cloud of every WP category. Any php aficianados know how to govern this plugin to only show categories with at least 50 posts? (I know its probably a greater than or equal to thing, just don't know how or where to put it) I've pared down the original plugin code to this for simplicity:

    http://jasonspage.net/docs/wpcatmap.txt

    Anybody? Thanks for any help WP folks.

  2. Joshua Sigar
    Member
    Posted 8 years ago #

    Okay, at your own risk, replace the following section of code ...
    $cat_counts = $wpdb->get_results("SELECT cat_ID,
    COUNT($wpdb->post2cat.post_id) AS cat_count
    FROM $wpdb->categories
    INNER JOIN $wpdb->post2cat ON (cat_ID = category_id)
    INNER JOIN $wpdb->posts ON (ID = post_id)
    WHERE post_status = 'publish'
    GROUP BY category_id");

    ..with the following...
    $cat_counts = $wpdb->get_results("SELECT cat_ID,
    COUNT($wpdb->post2cat.post_id) AS cat_count
    FROM $wpdb->categories
    INNER JOIN $wpdb->post2cat ON (cat_ID = category_id)
    INNER JOIN $wpdb->posts ON (ID = post_id)
    WHERE post_status = 'publish' AND cat_count > 50
    GROUP BY category_id");

  3. Kiddeath91
    Member
    Posted 8 years ago #

    Alphaoide,

    Thanks for the response. I did what you suggested and get this:

    WordPress database error: [Unknown column 'cat_count' in 'where clause']

  4. Joshua Sigar
    Member
    Posted 8 years ago #

    Okay, try this one

    $cat_counts = $wpdb->get_results("SELECT cat_ID,
    COUNT($wpdb->post2cat.post_id) AS cat_count
    FROM $wpdb->categories
    INNER JOIN $wpdb->post2cat ON (cat_ID = category_id)
    INNER JOIN $wpdb->posts ON (ID = post_id)
    WHERE post_status = 'publish'
    GROUP BY category_id
    HAVING cat_count > 50");

  5. Kiddeath91
    Member
    Posted 8 years ago #

    alphaoide

    You rock! That did it. THANKS!

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags