Hola! ¡Tenemos nuestra Comunidad en Español!

Creating a workflow email pulling blog posts by tag

SOLVE
Regular Contributor

Hello! I'm at my wits end trying to create an email for a workflow pulling the newest blog posts with a specific tag. I can pull recent posts, but whenever I re-code it to pull by tag, it breaks all the formatting.

 

Can't do an RSS email for the RSS feed because it can't be saved for automation and used in workflows.

 

Here's my code. The tag is "technical resources". Any help/guidance is MUCH appreciated!

{% set rec_posts = blog_recent_posts('4580349396', 2, tags="technical resources") %}
{% for rec_post in rec_posts %}
<div class="post-box">
<img style="width:100% !important; max-width:100% !important; height:auto !important " src="{{ rec_post.featured_image }}" alt="post-image">
<br>
<br>
<div class="post-content" style="padding-top:15px !important; padding-bottom:25px !important; padding:15px 20px 25px !important; font-family: 'Trebuchet MS', Arial, Helvetica, sans-serif">
<h2 style="font-family:Arial, Helvetica, sans-serif !important; width:100% !important; font-weight:700 !important; color:#555555 !important; line-height:24px !important; font-size:22px !important; margin:0 !important; padding:5px 0 15px !important;" class="post-title">{{ rec_post.name }}</h2>
<div class="post-cbyline" style="font-family: Arial, Helvetica, sans-serif; color:#555555 !important">
by <a class="author-link" style="text-decoration:none; color:#555555;" href="{{ group.absolute_url }}/author/{{ rec_post.blog_post_author.slug }}">{{ rec_post.blog_post_author.display_name }}</a>, {{ rec_post.publish_date|datetimeformat('%m/%e/%Y') }}
</div>
<p> {{ rec_post.post_list_content }} </p>
<div class="post-link" style="text-align:center">
<a class="more-link" style=" font-family: Arial, Helvetica, sans-serif !important; background:#0066ff !important; min-width:148px !important; height:40px !important; border-radius:5px !important; line-height:40px !important; text-align:center !important; color:#fff !important; text-transform:uppercase !important; font-weight:700 !important; margin-top:20px !important; display:inline-block !important; text-decoration:none !important; float:none !important; margin-bottom:0 !important; " href="{{rec_post.absolute_url }}"><span style="color:#fff !important;" >Read More</span></a>
</div>

</div> 
</div>
{% endfor %}

Thank you!

 

1 Accepted solution

Accepted Solutions
Highlighted
Regular Advisor

That's strange, it worked on my end when I tested. 

 

The only difference when I tried is that I used 'default' instead of the blog ID and my tags are all hyphenated (e.g. 'custom-module'). I wonder if you need to use a label such as

 

'technical-resources'

 instead.

 

Check out what appears in the topic URL (e.g. mine is 'http://www.stephanieogaygarcia.com/blog/topic/custom-module') and try using that instead. 

 


Stephanie O'Gay GarciaHubSpot Design / Development / Automation

Website | Contact

 

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

4 Replies 4
Regular Advisor

Hi there!

 

I'd recommend trying the following to set your recent posts instead: 

  

{% set rec_posts = blog_recent_topic_posts('4580349396', 'technical resources', 2) %} 

 

Let me know of that doesn't work!

 


Stephanie O'Gay GarciaHubSpot Design / Development / Automation

Website | Contact

 

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

Reply
0 Upvotes
Regular Contributor

Thanks for the reply, @Stephanie-OG! That previews as a blank email, though. :/

Reply
0 Upvotes
Highlighted
Regular Advisor

That's strange, it worked on my end when I tested. 

 

The only difference when I tried is that I used 'default' instead of the blog ID and my tags are all hyphenated (e.g. 'custom-module'). I wonder if you need to use a label such as

 

'technical-resources'

 instead.

 

Check out what appears in the topic URL (e.g. mine is 'http://www.stephanieogaygarcia.com/blog/topic/custom-module') and try using that instead. 

 


Stephanie O'Gay GarciaHubSpot Design / Development / Automation

Website | Contact

 

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

Regular Contributor

Yep, that did it @Stephanie-OG! Thank you so much for your help. I was really hoping it would be a small change like this. Smiley Happy

 

Thanks!

Reply
0 Upvotes