Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Author David Cavins

    (@dcavins)

    Hi there-

    BP Docs Tags are a custom taxonomy, so you’ll have to get the terms using custom taxonomy-friendly functions.

    For instance, to get all the docs tags that exist:
    $docs_tags = get_terms( 'bp_docs_tag' );
    To get all the docs tags associated with a particular post:
    $docs_tags = get_the_terms( int|object $post, 'bp_docs_tag' );

    Read more:
    https://developer.ww.wp.xz.cn/reference/functions/get_terms/
    https://developer.ww.wp.xz.cn/reference/functions/get_the_terms/

    Thread Starter drozdz94

    (@drozdz94)

    Hello. Thank you for the anserw.

    That works, but when I want to:
    echo $docs_tags[0]['name'];

    Then site is crashed

    Try using:

    $output = '';
    
    $doc_tags = wp_get_object_terms( $post->ID, 'bp_docs_tag' );
    
    foreach ($doc_tags as $tag_id => $tag) {
        $output .= ( $tag->name ).', ';
    }
    
    echo $output;

    Or something alike.
    Cheers.

    jjy

    UPDATE: In short, use object referentiation instead of array index.
    $tag->name instead of $tag[‘name’] … and check it out.

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

The topic ‘Function to show doc tags’ is closed to new replies.