This time, we used the HubL function blog_recent_tag_posts to create a list of articles that contain a specific tag on the blog article page.
Here is what the article list we created looks like:
blog-img
The three most recent articles with the same tags as the current article page are displayed in order of appearance.
There are three main points to note about this code:
POINT1: Get article tags
I want to use the tag specified on the current article page to retrieve articles that contain that tag, so
{% set tags = content.tag_list %}
This predefines the tags you've specified for the post in tags
. content is a default data object that contains information about the requested blog post.
POINT2: Use the blog_recent_tag_posts function to get posts containing a specific tag
The blog_recent_tag_posts function allows you to return a sequence of blog post objects for a given tag(s), sorted by most recent.
When using it,
you can specify the following belgium b2b leads three parameters: selected_blog: which blog to use
tag_slug: the tag to narrow down (multiple tags can be specified)
limit: the number of posts to add to the sequence
. Therefore, by specifying the parameters as follows,

{% set related_posts = blog_recent_tag_posts("default", tags,3) %}
You can add up to three posts from your default blog to your sequence that have the same tags as the current post page, in reverse chronological order.
POINT3: Display the articles retrieved with for
{% for post in related_posts %} ~ {% endfor %}
Next, we use a for statement to loop through the items we want to output for the retrieved articles (in this case, article URL, thumbnail, title, and tags).
That's all for the code explanation.
This time we were narrowing down the results by tag, so we used blog_recent_tag_posts , but if you want to obtain the authors of articles or articles published within a certain period of time, this can be achieved by using the blog_authors and start_date parameters of the related_blog_posts tag .
If I have the opportunity, I would also like to create a list of articles using the related_blog_posts tag.