Skip to:
Content
Pages
Categories
Search
Top
Bottom

Count topics with specific tag


  • Loc Pham
    Participant

    @phamdacloc

    I need your advice on how to count the number of topics associated with a specific tag. Is there a function already available or do I have to write my own? I’m needing this piece of data to include in WP-REST response.

    Any help would be greatly appreciated. Thanks.

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

  • Robkk
    Moderator

    @robkk

    I think bbPress just uses the code from WordPress since the topic tag clouds code is close to WordPress’s version for regular posts.

    You can see the tag cloud on hover displays the number of topics.

    https://bbpress.org/forums/

    I tried searching what it was, but couldn’t really pinpoint the exact function.

    Hi,

    If it can help, check shortcodes. The 2nd one could be your starting point:
    [bbp-topic-tags] – Display a tag cloud of all topic tags.
    [bbp-single-tag id=$tag_id] – Display a list of all topics associated with a specific tag. eg. [bbp-single-tag id=64]

    See https://codex.bbpress.org/features/shortcodes/

    Pascal.


    Loc Pham
    Participant

    @phamdacloc

    With a combination of two methods, I was able to get the number of topics per tag. These methods query the taxonomies of bbPress’ topic-tag:

    $tagList = get_the_terms($post->ID, bbp_get_topic_tag_tax_id());

    The output of $tagList is as follow and ‘count’ is what i’m interested in:

    {
    term_id: 24
    name: “Presidential”
    slug: “presidential”
    term_group: 0
    term_taxonomy_id: 24
    taxonomy: “topic-tag”
    description: “”
    parent: 0
    count: 3
    object_id: 155
    filter: “raw”
    }

    Hope this helps others.


    wallacelin
    Participant

    @wallacelin

    Hi,

    This topic is quite old but it seems to be the only one about displaying tagged topics count. How would you implement the query to count topic tags? Is it possible to create a custom shortcode to show the tag count? Any help with this would be greatly appreciated, thanks!

Viewing 4 replies - 1 through 4 (of 4 total)
  • You must be logged in to reply to this topic.
Skip to toolbar