WordPress.org

Support

Support » Plugins and Hacks » PHP plugin mod.

PHP plugin mod.

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

Viewing 4 replies - 1 through 4 (of 4 total)
  • 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");

    Alphaoide,

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

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

    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");

    alphaoide

    You rock! That did it. THANKS!

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘PHP plugin mod.’ is closed to new replies.
Skip to toolbar