Using Tag Groups: Displaying groups and adjacent tags of current post
I am trying to use tag groups (plugin) and tags as a way to display basic info on a portfolio/blog website’s posts. I have organised them as *ex. Tag Group: Year / Tags: 2012, 2013, 2014… etc and tag each post with one tag from each group. What I want to display on a post/project page is Year: 2013, – display the name of the group and the adjacent tag for this post only.
So far, I have made a table and managed to display only adjacent tag groups, but I cannot filter the tag for the post. As an output I get “Group: All tags in it”.
I am building the site myself and started with all web coding from zero a couple of months ago, so any help would be appreciated. I think that I miss a condition in the “foreach” function, but I am not sure at all.
This is the code:
$groups = tag_groups_cloud( array( ‘groups_post_id’ => ‘0’, ‘orderby’ => ‘count’, ‘order’ => ‘DESC’ ) , true );
<table>
<tr>
<?php if ( $groups ) foreach ( $groups as $group ): ?>
<th><?php echo $group['name'] ?></th>
<?php endforeach; ?>
</tr>
<tr>
<?php foreach ( $groups as $group ): ?>
<td>
<ul>
<?php
foreach ($group['tags'] as $tag ):
?>
<li>
<a href="<?php echo $tag['link'] ?>"><?php echo $tag['name'] ?></a></li>
<?php endforeach; ?>
</ul>
</td>
<?php endforeach; ?>
</tr>
</table>
Leave an answer