blog_recent_tag_posts

SOLVE
Philip_Marsh
Contributor

Hi,
I have created a module which automatically pulls in the latest blog posts.

The following code works perfectly.

 

{% set tag_posts = blog_recent_tag_posts('default', ['tag'], 4) %}
{% for tag_post in tag_posts %}

 

However, I want to be able to control which tag to show on individual pages manually. I have a tag field set up, but is there anyway for me to input the tag field directly into ['tag']?

 

I understand you can't have {{ inside {%, so ('default', [' {{ module.tag_field}}'], 4) wouldn't work.

0 Upvotes
1 Accepted solution

Accepted Solutions
Stephanie-OG
Solution
Key Advisor

Hi Philip, there is indeed!

 

If you have the "Tag" field on your module (with the internal name "tag_field"), the following should work:

 

{% set tag_posts = blog_recent_tag_posts('default', module.tag_field, 4) %}

You don't need to add the brackets again when you're setting your variable.

 

I hope that helps.

 


Stephanie O'Gay Garcia

HubSpot CMS Design & Development

Website | Contact

 

If this helped, please mark it as the solution to your question, thanks!

View solution in original post

2 Replies 2
Stephanie-OG
Solution
Key Advisor

Hi Philip, there is indeed!

 

If you have the "Tag" field on your module (with the internal name "tag_field"), the following should work:

 

{% set tag_posts = blog_recent_tag_posts('default', module.tag_field, 4) %}

You don't need to add the brackets again when you're setting your variable.

 

I hope that helps.

 


Stephanie O'Gay Garcia

HubSpot CMS Design & Development

Website | Contact

 

If this helped, please mark it as the solution to your question, thanks!

View solution in original post

Philip_Marsh
Contributor

Brilliant, that works. I thought I tried that but I think i may have just left in the ['']

 

Thank you

0 Upvotes