Skip to:
Content
Pages
Categories
Search
Top
Bottom

Custom Query

  • Avatar of scottwermter
    Scott
    Participant

    @scottwermter

    I am not a programmer and I am probably missing something really obvious. I have custom tags installed and setup for my groups. I want to run a query that displays the total count of how many groups has a certain tag.

    I have been trying something like this. Any ideas?

    `
    function TagCount() {
    global $wpdb, $bp;
    $var_count = $wpdb->get_var(“SELECT count( * ) FROM $bp->groups_groupmeta WHERE meta_key = ‘gtags_group_tags’ AND meta_value = ‘%MyTag%’;”);

    echo ‘count is ‘ . $var_count . ”;
    }
    add_shortcode(‘tagcount’, ‘TagCount’);
    ?>
    `

Viewing 2 replies - 1 through 2 (of 2 total)
  • Avatar of scottwermter
    Scott
    Participant

    @scottwermter

    Anyone have any ideas?

    Avatar of scottwermter
    Scott
    Participant

    @scottwermter

    In case anyone else wonders, this is how I did it.

    `
    add_shortcode(‘factioncount’, ‘FactionCount’);
    function FactionCount() {
    global $wpdb;

    //my table
    $table = $wpdb->prefix . “bp_groups_groupmeta”;

    prefix . “bp_groups_groupmeta”;

    //query for my tags
    $ald_tags = $wpdb->get_results(“SELECT * FROM {$table} WHERE meta_key = ‘gtags_group_tags’ AND meta_value LIKE ‘%aldmeri-dominion%’”);

    $ald_tags = (array_filter($ald_tags));

    print_r($ald_tags);

    $ald_tags = count(array_keys($ald_tags));
    return $ald_tags;

    }
    ?>
    `

Viewing 2 replies - 1 through 2 (of 2 total)

You must be logged in to reply to this topic.