Support » Plugin: Tag Groups » List of tags in a tag group

  • Resolved sanguine1

    (@sanguine1)


    I need a simple list of the tags that belong to a tag group
    group A has tags: one, two, three
    group B has tags: four, five, six

    how do i say, give me the tags in group A with PHP and it tell me
    one, two, three

    I have example code, that displays tags in a list
    i know i need to somehow use
    wp_tag_cloud()
    but i am unsure how to use it to get the results in the same way the code below would hand me the tags

    Basically i guess im asking how do i get an array of the tags in a tag group, by tag group name?

    add_action( 'the_content', 'list_tags' );
    function list_tags ( $content ) {
    	if ( is_page('sample-page')) {
    		$tags = get_tags();
    		$html = '<ul>';
    		foreach ( $tags as $tag ) {
    				$html .= "<li>{$tag->name}</li>";
    		}
        	$html .= '</ul>';
    		echo $html;
    	}
    	else {
        return $content;
        }
    
    }
    • This topic was modified 1 month, 3 weeks ago by  sanguine1.
    • This topic was modified 1 month, 3 weeks ago by  sanguine1.
Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Author Chris

    (@camthor)

    You could use something like this:

    
    if ( function_exists( 'tag_groups_cloud' ) ) {
      $groups = tag_groups_cloud( array( 'include' => '1,3' ) , true ); // for the groups where the IDs are  1 and 3
      foreach ( $groups as $group ) {
        $html = '<ul>';
        foreach ( $group['tags'] as $tag ) {
          $html .= "<li>{$tag['name']}</li>";
        }
        $html .= '</ul>';
        echo $html;
      }
    }
    
    

    I haven’t tested it.

    well it works i thank you, the output was exactly what i wanted. thank you so very much. i literally spent hours lol.

    add_action( 'the_content', 'list_tags_bygroup' );
    
    function list_tags_bygroup ( $content ) {
    	if ( is_page('sample-page')) {
    		$arrays = tag_groups_cloud( array( 'orderby' => 'count', 'order' => 'DESC' ) , true  );
    		$html = '<ul>';
        	for ($i = 0; $i < sizeof($arrays); $i++) {
        		$html .= "<li>{$arrays->name}</li>";
            }   
            $html .= '</ul>';
    		echo $html;
        }
    }

    that was as far as i got, i think i almost made it myself. Thanks again

    Plugin Author Chris

    (@camthor)

    You’re welcome! 🙂

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