CMS Development

Philip_Marsh
投稿者

blog_recent_tag_posts

解決

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 いいね!
1件の承認済みベストアンサー
Stephanie-OG
解決策
キーアドバイザー

blog_recent_tag_posts

解決

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!

元の投稿で解決策を見る

2件の返信
Stephanie-OG
解決策
キーアドバイザー

blog_recent_tag_posts

解決

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!

Philip_Marsh
投稿者

blog_recent_tag_posts

解決

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

 

Thank you

0 いいね!