Site icon Hip-Hop Website Design and Development

Counting variety of similar meta keys

Im seeking to depend what number of meta keys exist inside a publish, as a result of every time a selected person motion occurs, a brand new meta secret’s created with a date in it.

I’ve this, which doesn’t return something (I am on the lookout for a quantity)…

        ...
$post_title = $row->post_title;
        $id = $row->ID;

$post_count = $wpdb->get_var("
                SELECT COUNT(DISTINCT $wpdb->postmeta.meta_key) FROM $wpdb->posts
                LEFT JOIN $wpdb->postmeta 
                WHERE $wpdb->posts.post_type = 'issues'
                AND $wpdb->postmeta.meta_key = 'dates' 
                AND post_id = $id
                ");

        echo $post_title . ' (' . $post_count . ')' . "n";
    }

Equally, I would wish to depend the variety of meta keys in complete associated to a customized publish, any assistance on both of those can be tremendously appreciated!