# Alternative to querying post using content\_by\_id()

**URL:** <https://community.hubspot.com/t/alternative-to-querying-post-using-content-by-id/51438>\
**Category:** CMS Development\
**Tags:** design-manager, local-development\
**Created:** [February 12, 2022, 7:03pm UTC](https://community.hubspot.com/t/alternative-to-querying-post-using-content-by-id/51438 "2022-02-12T19:03:05Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Amit\_95](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/amit_95/32/74736_2.png) [@Amit\_95](https://community.hubspot.com/u/Amit_95)\
**Post date:** [February 12, 2022, 7:03pm UTC](https://community.hubspot.com/t/alternative-to-querying-post-using-content-by-id/51438/1 "2022-02-12T19:03:05Z")

</div>

I have a _ **link** _ field which allows a user to select a post or page from HubSpot.

Then, I’m using the _ **id** _ to query that _ **link** _ field using _**content\_by\_id()**_. However, this function and content\_by\_ids() has a cap of 10 calls per page.

I cannot change the _ **link** _ field type and I’m using that field type because I need:

- The post / page title
- The post / page url

A single field helps achieve both as I can access the object.

But as mentioned, I need a way to get this working for pages which have more than 10 link items.

See my current approach:

```lia-code-sample
{% for item in module.tag %}

 {% set href = item.url.href %}
 {% set content_id = item.url.content_id %}
 {% set get_title = content_by_id(content_id) %}

 <li class="words__li">
 <a href="{{ href }}" class="words__link" {% if item.open_in_new_tab %}target="_blank"{% endif %} {% if item.rel %}rel="{{ item.rel }}"{% endif %}>
 {{ get_title.title }}
 </a>
 </li>

{% endfor %}

```

Any ideas?

---

<div class="post-metadata">

**Author:** ![dennisedson](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/dennisedson/32/28044_2.png) [@dennisedson](https://community.hubspot.com/u/dennisedson)\
**Post date:** [February 15, 2022, 6:26pm UTC](https://community.hubspot.com/t/alternative-to-querying-post-using-content-by-id/51438/2 "2022-02-15T18:26:38Z")

</div>

@stefen , any suggestions for this?

---

<div class="post-metadata">

**Author:** ![albertsg](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/albertsg/32/99473_2.png) [@albertsg](https://community.hubspot.com/u/albertsg)\
**Post date:** [February 15, 2022, 7:14pm UTC](https://community.hubspot.com/t/alternative-to-querying-post-using-content-by-id/51438/3 "2022-02-15T19:14:23Z")

</div>

Hi [@Amit\_95](https://community.hubspot.com/t5/user/viewprofilepage/user-id/64311), 10 calls per page using [content\_by\_ids](https://developers.hubspot.com/docs/cms/hubl/functions#content-by-ids) means 1000 posts/pages. Would you need more than 1000 links?  
Notice that content\_by\_ids returns up to 100 elements while content\_by\_id returns only 1.

content\_by\_id() --\> 10 calls \* 1 page/call = 10 pages

content\_by\_ids() --\> 10 calls \* 100 pages/call = 1000 pages

You could store all the IDs into an array and use contents\_by\_ids() to get all your data in just one call 🙂

---

<div class="post-metadata">

**Author:** ![Amit\_95](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/amit_95/32/74736_2.png) [@Amit\_95](https://community.hubspot.com/u/Amit_95)\
**Post date:** [February 15, 2022, 7:32pm UTC](https://community.hubspot.com/t/alternative-to-querying-post-using-content-by-id/51438/4 "2022-02-15T19:32:12Z")

</div>

Hi @albertsg ,

Thanks for clarifying, managed to get it working 🙂

For anyone looking for a solution, here’s how I did it:

```lia-code-sample
<!-- add items to array -->

{% set array = [] %}

{% for item in module.tag %}
 {% do array.append( item.url.content_id ) %}
{% endfor %}

{% set contents = content_by_ids(array) %}

{% for content in contents %}
	<li class="words__li">
 <a href="{{ content.absolute_url }}" class="words__link" {% if content.open_in_new_tab %}target="_blank"{% endif %} {% if content.rel %}rel="{{ content.rel }}"{% endif %}>
 {{ content.title }}
 </a>
 </li>
{% endfor %}

```
