0

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>

1 Answer 1

0

If I understood your request correctly, then you probably need a different parameter: tags_post_id

$groups = tag_groups_cloud( array( 'tags_post_id' => '0', 'orderby' => 'count', 'order' => 'DESC' ) , true );

I tried it and the output is only the tags of that post, but arranged in a table.

The parameter groups_post_id is used for selecting groups that are connected to the post, while tags_post_id selects the tags.

See the complete description of the parameters.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.