CMS Development

m_engineer
Membre

I want to get tags in blog_recent_posts

Résolue

I want to use the HubL function blog_recent_posts to display tags.
Is there any way to do this?

 

```

{% set rec_posts = blog_recent_posts(11111111111, 10) %}

{% for rec_post in rec_posts %}

  <span class="category">{{rec_posts.tag }}</span>

{% endfor %}

```

0 Votes
1 Solution acceptée
MBERARD
Solution
Contributeur de premier rang | Partenaire solutions Elite
Contributeur de premier rang | Partenaire solutions Elite

I want to get tags in blog_recent_posts

Résolue

My bad! I misinterpreted your original request... So you want to do something like that to retrieve the tags: 

{% set rec_posts = blog_recent_posts(11111111111, 10) %}
{% for rec_post in rec_posts %}
<div class="article">
  <a class="list-link" href="{{rec_post.url}}">
    {% for tag in rec_post.tag_list %}
      <div class="category">{{ tag.name }}</div>
    {% endfor %}
    <div class="title">{{ rec_post.name }}</div>
  </a>
</div>
{% endfor %}

 

Matthieu

matthieu.berard@markentive.com

Voir la solution dans l'envoi d'origine

4 Réponses
MBERARD
Contributeur de premier rang | Partenaire solutions Elite
Contributeur de premier rang | Partenaire solutions Elite

I want to get tags in blog_recent_posts

Résolue

Hi @m_engineer ,

If you only want to display tags from a specific blog you should use the blog_tags function instead.
You can find details on the documentation here.

Here is a qucik resume on how you use it:

{% set my_tags = blog_tags(11111111111, 10) %}
<ul>
  {% for item in my_tags %}
    <li><a href="{{ blog_tag_url(group.id, item.slug) }}">{{ item }}</a></li>
  {% endfor %}
</ul>

 Hope it helps 😊

 

Matthieu

matthieu.berard@markentive.com

0 Votes
m_engineer
Membre

I want to get tags in blog_recent_posts

Résolue

Thank you for your response.

How can I retrieve new posts and display tag information from the retrieved posts?

Is it possible to use the blog_tags function?

 

 

{% set rec_posts = blog_recent_posts(11111111111, 10) %}
{% for rec_post in rec_posts %}
<div class="article">
  <a class="list-link" href="{{rec_post.url}}">
    <div class="category">{{ rec_post.tag }}</div>
    <div class="title">{{ rec_post.name }}</div>
  </a>
</div>
{% endfor %}

 

 

0 Votes
MBERARD
Solution
Contributeur de premier rang | Partenaire solutions Elite
Contributeur de premier rang | Partenaire solutions Elite

I want to get tags in blog_recent_posts

Résolue

My bad! I misinterpreted your original request... So you want to do something like that to retrieve the tags: 

{% set rec_posts = blog_recent_posts(11111111111, 10) %}
{% for rec_post in rec_posts %}
<div class="article">
  <a class="list-link" href="{{rec_post.url}}">
    {% for tag in rec_post.tag_list %}
      <div class="category">{{ tag.name }}</div>
    {% endfor %}
    <div class="title">{{ rec_post.name }}</div>
  </a>
</div>
{% endfor %}

 

Matthieu

matthieu.berard@markentive.com

m_engineer
Membre

I want to get tags in blog_recent_posts

Résolue

This is exactly the answer I was looking for!
Thank you very much.