# How to create a relationship module

**URL:** <https://community.hubspot.com/t/how-to-create-a-relationship-module/55777>\
**Category:** CMS Development\
**Created:** [April 27, 2022, 2:59pm UTC](https://community.hubspot.com/t/how-to-create-a-relationship-module/55777 "2022-04-27T14:59:35Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Vmarques9](https://avatars.discourse-cdn.com/v4/letter/v/54ee81/32.png) [@Vmarques9](https://community.hubspot.com/u/Vmarques9)\
**Post date:** [April 27, 2022, 2:59pm UTC](https://community.hubspot.com/t/how-to-create-a-relationship-module/55777/1 "2022-04-27T14:59:35Z")

</div>

Hi,

I’d like to create a relationship module. A Relationship field provides a dual-column component to select one or more posts. The ideia is to create someting like a relation acf from worpdress, u could see an example [here.](https://www.advancedcustomfields.com/resources/relationship/)

It is necessary to have a list with a checkbox field so that the desired option is chosen, those selected items will appear in the frontend.

Please let me know if my explanation was bad.

---

<div class="post-metadata">

**Author:** ![Anton](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/anton/32/103167_2.png) [@Anton](https://community.hubspot.com/u/Anton)\
**Post date:** [April 28, 2022, 6:51pm UTC](https://community.hubspot.com/t/how-to-create-a-relationship-module/55777/2 "2022-04-28T18:51:00Z")

</div>

Hi @Vmarques9,

sure this is possible. Unfortunately you’ll need to write all your options manually. There is noo option to “grab” tags automatically and display them in a custom module select option.

Something like “show x posts with tag y” would perfectly work with the [blog\_recent\_tag\_posts](https://developers.hubspot.com/docs/cms/hubl/functions#blog-recent-tag-posts) function.

The custom module could look like this:

- add a blog to select (“blog”)

- add a select/coice option(“tags”)

- add a number option (“tag\_count”)

```lia-code-sample
{% set tag_posts = blog_recent_tag_posts("module.blog_select", module.tags, module.tag_count) %}

<ul>{# for demo purposes #}

{% for post in tag_posts %}
<li>{{post.name}}</li>
{# your layout for each post comes here #}
{% endfor %}

</ul>

```

you can modify/expand it with options to what ever you’d like to have.

For example - you’d like to change the layout(s): add a select option(“layout\_selector”) and write the code like this

```lia-code-sample
{% set tag_posts = blog_recent_tag_posts("module.blog_select", module.tags, module.tag_count) %}

{% if module.layout_selector == "layout_1" %}
{# layout 1 #}
{% elif module.layout_selector == "layout_2" %}
{# layout 2 #}
{% else %} {# fallback/failsafe; optional if you don't have any option selected #}
{# fallback layout #}
{% endif %}

```

hope this helps

best,

Anton
