Support

Account

Home Forums General Issues Count of posts with the same field choice Reply To: Count of posts with the same field choice

  • @LeffDesign,

    Try this function: https://gist.github.com/wells5609/5944561

    It counts posts of a given post type with either a meta_key, meta_value, or key/value pair. Results are cached for 3 hours (you can change this depending on how often the post count will change). Use in a template like:

    $post_count = get_post_count_by_meta('some_key', 'some_value', 'some-post-type');
    echo $post_count;