# Add authors to a dropdown list

**URL:** <https://community.hubspot.com/t/add-authors-to-a-dropdown-list/117115>\
**Category:** CMS Development\
**Created:** [September 26, 2024, 10:22am UTC](https://community.hubspot.com/t/add-authors-to-a-dropdown-list/117115 "2024-09-26T10:22:35Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![RAnderson91](https://avatars.discourse-cdn.com/v4/letter/r/8baadc/32.png) [@RAnderson91](https://community.hubspot.com/u/RAnderson91)\
**Post date:** [September 26, 2024, 10:22am UTC](https://community.hubspot.com/t/add-authors-to-a-dropdown-list/117115/1 "2024-09-26T10:22:35Z")

</div>

Hi,

I’m relatively new to HubSpot development. I’m creating a custom module that would allow users to add a curated list of authors to a page, working almost like a team members page.

I’ve found a piece of code that adds all the authors to a page (see below), however I want the user to be able to add authors via a repeater and customise the order they are in.

{{ blog\_authors(“default”, 250) }}

{% set my\_authors = blog\_authors(“default”, 250) %}

\<ul\>

{% for author in my\_authors %}

\<li\>\<a href=“{{ blog\_author\_url(group.id, author.slug) }}”\>{{ author }}\</a\>\</li\>

{% endfor %}

\</ul\>

I also found this article ([https://community.hubspot.com/t5/CMS-Development/Multiple-authors-for-blog/m-p/701150#M30700](https://community.hubspot.com/t5/CMS-Development/Multiple-authors-for-blog/m-p/701150#M30700)) that allows users to add a second author to a blog post, but I couldn’t figure out how to adapt it to work in a custom module.

I realize we could use something like HubDB to create this, but the idea would be that you could click a link and it would take you to the authors page and see all the posts they have created.

Any help is greatly appreciated.

---

<div class="post-metadata">

**Author:** ![sshah218](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/sshah218/32/203967_2.png) [@sshah218](https://community.hubspot.com/u/sshah218)\
**Post date:** [September 26, 2024, 12:36pm UTC](https://community.hubspot.com/t/add-authors-to-a-dropdown-list/117115/2 "2024-09-26T12:36:29Z")

</div>

Welcome to HubSpot development! It sounds like you have a great idea for a custom module to curate a list of authors. To achieve this, you can use HubSpot’s custom modules with repeaters to allow users to add and order authors as needed. Here’s a step-by-step guide to help you implement this:

1. **Create a Custom Module:**

---

<div class="post-metadata">

**Author:** ![Teun](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/teun/32/28739_2.png) [@Teun](https://community.hubspot.com/u/Teun)\
**Post date:** [September 26, 2024, 2:46pm UTC](https://community.hubspot.com/t/add-authors-to-a-dropdown-list/117115/3 "2024-09-26T14:46:35Z")

</div>

Hi @RAnderson91 ,

One way you can achieve this, is creating a repeater field in your module where you allow the user to store the slug of the authors they want to display.  
In your code, you can then filter out all the authors you want to display based on the values you have stored in the repeater field:

```lia-code-sample
{% set my_authors = blog_authors(group.id, 250) %}

<ul>
{% for author_to_display in module.authors_to_display %}
 {% set author = my_authors|selectattr('slug', 'eq', author_to_display.slug) %}
 {% if author %}
 <li><a href="{{blog_author_url(group.id, author.slug)}}">{{author}}</a></li>
 {% endif %}
{% endfor %}
</ul>

```

The code above assumes that you create a repeater field inside your module call ‘authors\_to\_display’ with a single-line text field called ‘slug’.

---

<div class="post-metadata">

**Author:** ![RAnderson91](https://avatars.discourse-cdn.com/v4/letter/r/8baadc/32.png) [@RAnderson91](https://community.hubspot.com/u/RAnderson91)\
**Post date:** [September 26, 2024, 3:13pm UTC](https://community.hubspot.com/t/add-authors-to-a-dropdown-list/117115/4 "2024-09-26T15:13:59Z")

</div>

Hi @Teun

Thanks for the response, here are some screenshots of how I have set it up, is this correct?

 ![authors-1.jpg](https://d2qpr2jzcazej7.cloudfront.net/original/3X/2/d/2dff6311022bc412562f99a5d00c3e53e73d4cd9.jpeg)

 ![authors-2.jpg](https://d2qpr2jzcazej7.cloudfront.net/original/3X/f/5/f532d584f72b17688f19a9cf58a539dc399f74a1.jpeg)

---

<div class="post-metadata">

**Author:** ![Teun](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/teun/32/28739_2.png) [@Teun](https://community.hubspot.com/u/Teun)\
**Post date:** [September 26, 2024, 3:57pm UTC](https://community.hubspot.com/t/add-authors-to-a-dropdown-list/117115/5 "2024-09-26T15:57:20Z")

</div>

Hi @RAnderson91 ,

Yes, this is exactly what I meant!

---

<div class="post-metadata">

**Author:** ![RAnderson91](https://avatars.discourse-cdn.com/v4/letter/r/8baadc/32.png) [@RAnderson91](https://community.hubspot.com/u/RAnderson91)\
**Post date:** [September 27, 2024, 8:24am UTC](https://community.hubspot.com/t/add-authors-to-a-dropdown-list/117115/6 "2024-09-27T08:24:38Z")

</div>

Hi @Teun,

Thanks for confirming, am I correct in assuming that this could be adapted to include grabbing things like the author image, bio, etc?

---

<div class="post-metadata">

**Author:** ![Teun](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/teun/32/28739_2.png) [@Teun](https://community.hubspot.com/u/Teun)\
**Post date:** [September 27, 2024, 8:28am UTC](https://community.hubspot.com/t/add-authors-to-a-dropdown-list/117115/7 "2024-09-27T08:28:07Z")

</div>

Hi @RAnderson91,

That should already be available in the author variable:

```lia-code-sample
{% set my_authors = blog_authors(group.id, 250) %}

<ul>
{% for author_to_display in module.authors_to_display %}
 {% set author = my_authors|selectattr('slug', 'eq', author_to_display.slug) %}
 {% if author %}
 {% set image = author.avatar %}
 {% set name = author.display_name %}
 <li><a href="{{blog_author_url(group.id, author.slug)}}">{{author}}</a></li>
 {% endif %}
{% endfor %}
</ul>

```

---

<div class="post-metadata">

**Author:** ![RAnderson91](https://avatars.discourse-cdn.com/v4/letter/r/8baadc/32.png) [@RAnderson91](https://community.hubspot.com/u/RAnderson91)\
**Post date:** [September 27, 2024, 1:42pm UTC](https://community.hubspot.com/t/add-authors-to-a-dropdown-list/117115/8 "2024-09-27T13:42:02Z")

</div>

Hi @Teun

Thanks for the updated code, though I’ve noticed that the name is outputting the name of the widget and not the author, along with not being able to output the avatar. I also noticed that the author url is merely the link to the current page.

{% set my\_authors = blog\_authors(group.id, 250) %}

\<ul\>  
{% for author\_to\_display in module.authors\_to\_display %}  
{% set author = my\_authors|selectattr(‘slug’, ‘eq’, author\_to\_display.slug) %}  
{% if author %}  
{% set image = author.avatar %}  
{% set name = author.display\_name %}  
\<li\>  
\<a href=“{{blog\_author\_url(group.id, author.slug)}}”\>{{author}}\</a\>  
\<img src=“{{ image }}” /\>  
\<p\>{{ name }}\</p\>  
\</li\>  
{% endif %}  
{% endfor %}  
\</ul\>

You can see the result here [https://45411996.hs-sites.com/team](https://45411996.hs-sites.com/team)

---

<div class="post-metadata">

**Author:** ![Teun](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/teun/32/28739_2.png) [@Teun](https://community.hubspot.com/u/Teun)\
**Post date:** [September 27, 2024, 5:50pm UTC](https://community.hubspot.com/t/add-authors-to-a-dropdown-list/117115/9 "2024-09-27T17:50:07Z")

</div>

Hi @RAnderson91 ,

Are you displaying this on a website page? If so, the code needs to be a bit different. Can you try the following?

```lia-code-sample
{% set my_authors = blog_authors('default', 250) %}

<ul>
{% for author_to_display in module.authors_to_display %}
 {% set author = my_authors|selectattr('slug', 'eq', author_to_display.slug) %}
 {% if author %}
 {% set image = author.avatar %}
 {% set author_name = author.display_name %}
 <li><a href="{{blog_author_url('default', author.slug)}}">{{author_name}}</a></li>
 {% endif %}
{% endfor %}
</ul>

```
