Site icon Hip-Hop Website Design and Development

Return all Tags and Classes in Separate Record

I’m utilizing the snippet beneath to create a shortcode to get all tags for a search in a separate record together with tag rely. Eg seek for ‘foo’ and it returns all tags for all posts that match the search ‘foo’.

I’m attempting to additionally get the classes from the identical search in a separate record utilizing a second shortcode from the identical international search. I’m not certain how I can get the classes from the identical international search.

Eg seek for for ‘foo’ and get:

Tag: Tag1 (10), Tag2 (20), Tag3 (2) and so on (that is the shortcode and already works)

Class: Cat1 (10), Cat2 (2) and so on. (unsure get the second shortcode to work)

    operate get_query_terms_list( $taxonomy = 'post_tag', $sep = '' ) {
    $record = array();

    foreach ( $GLOBALS['wp_query']->posts as $submit ) {
        if ( is_array( $phrases = get_the_terms( $submit, $taxonomy ) ) ) {
            foreach ( $phrases as $time period ) {
                // Set the time period's preliminary rely.
                if ( ! isset( $record[ $term->term_id ] ) ) {
                    $record[ $term->term_id ] = 0;
                }
                // After which increment it for every submit.
                $record[ $term->term_id ]++;
            }
        }
    }

    // Kind by the rely, highest to lowest.
    arsort( $record );

    $hyperlinks = array();

    foreach ( $record as $term_id => $rely ) {
        $time period = get_term( $term_id );
        $hyperlink = get_term_link( $time period );

        if ( ! is_wp_error( $hyperlink ) ) {
            $hyperlinks[] = '<a mode="background-color:#fffff; border-radius:20px; box-shadow: 0 3px 5px 0 rgb(0 0 0 / 8%); font-weight: bold; color:#6c757d; padding:8px; margin:5px;" href="'.$link.'">' . __( $term->title ) ." ($count)". '</a>'.'';
            
        }
    }

    return '<div model="height:50px; padding-top:10px; overflow-x:auto; white-space: nowrap;">'.implode( $sep, $hyperlinks ).'</div>';
}

Shortcode

add_shortcode( 'bd_terms_list', 'bd_terms_list_custom_callback');
operate bd_terms_list_custom_callback( $args ){
    return get_query_terms_list( 'gd_place_tags' );
}