Blended RSS feed Email

Interesting scenario here:

We recently divided our corporate blog into two blogs, one for the product and one for the corporation, to help focus the content and prepare for future growth on each blog. However, we want to keep the subscriber experience the same for our 150,000+ subscribers and blend the two feeds.

My solution has been to piggyback the exisiting blog notification email with the following code:

{% set posts = blog_recent_posts('5311301086', 2) %} {% for post in posts %} <a href="{{post.url}}"><img src="{{post.featured_image}}"></a>
<h2 style="padding-bottom: 0; margin: 0 0 5px 0;"><span style="font-size: 24px; color: #1b4298;"><a href="{{post.url}}" style="color: #1b4298;">{{post.title}}</a></span></h2>
<p style="padding-top: 0; margin-top: 0;"><span style="color: {{secondary_font_color}}; font-style: italic; font-size: 14px;">{{post.publish_date}}</span></p>
<div><span style="color: #444444; font-size: 16px;">{{post.summary}}</span></div>/* =====MOBILE FRIENDLY BUTTON===== */
<table style="border-collapse: collapse; border-spacing: 0;" border="0" width="100%" cellspacing="0" cellpadding="0">
<tbody>
<tr>
<td style="padding: 20px 0 20px 0;">
<table style="border-collapse: collapse; border-spacing: 0;" border="0" cellspacing="0" cellpadding="0" align="center">
<tbody>
<tr>
<td style="-webkit-text-size-adjust: 100%; -ms-text-size-adjust: 100%; mso-table-lspace: 0pt; mso-table-rspace: 0pt;" align="center"><a class="mobile-button" href="{{post.url}}" style="-webkit-text-size-adjust: 100%; -ms-text-size-adjust: 100%; font-size: 18px; font-family: Open Sans, Helvetica, Arial,sans-serif; font-weight: normal; color: {{body_color}}; text-decoration: none; border-radius: 15px; background-color: #1b4298; border-top: 10px solid #1B4298; border-bottom: 10px solid #1B4298; border-right: 22px solid #1B4298; border-left: 22px solid #1B4298; display: block;" target="_blank">Read More →</a></td>
</tr>
</tbody>
</table>
</td>
</tr>
</tbody>
</table>
{% endfor %}

And where this is working for the most part it’s not pulling the the post summary and I’m getting duplicate posts. Any help would be greatly appreciated.

@brentswashburn,

Right off the bat I notice that your blog post variables aren’t going to work. Your variables should use the the single item name of your loop, “.”, then the variable. You can find the list of variables here.

Example:

{% for item in loop_items %}
 {{ item.name }}
 {{ item.absolute_url }}
 {{ item.featured_image }}
 {{ item.post_body }}
{% endfor %}

You want to make sure your variables are correct.

As for your rss feeds, it isn’t clear on what you are trying to do. Are you wanting to combine 2 blogs? You can do that like this:

{% set blog_one_posts = blog_recent_posts('default', limit=5) %} 
{% set blog_two_posts = blog_recent_posts('47082700', limit=5) %} 
{% set all_posts = (blog_one_posts + blog_two_posts) | sort(true, false, 'publish_date') %}

{% for item in all_posts %}
 {{ item.name }}
 {{ item.absolute_url }}
 {{ item.featured_image }}
 {{ item.post_body }}
{% endfor %}

@Jsum thank you! This is very promising, do you know of a way to filter out images from post summarys? Also, the limit setting does not seem to work, I am continuing to get duplicate posts throughout the email. Thoughts?

Thanks again!

@brentswashburn,

To get rid of the images in the summary, first there is a setting under content->content settings → blog. it is a check box that asks if you would like to use images in the listing summary.

second you should use this token for your summary

{{ content.post_list_content }}

where content is the name of the single item in your loop.

as for duplications, the recent blogs function works like this:

it pulls the most recent blogs from your blog at the limit you set. Since you are using 2 function with a limit of 5 and combining them you should recieve the 5 most recent blogs from each blog for a total of ten. If you are recieving duplicate posts then

1. your posts are duplicated with your blogs

2. your posts are duplicated across your blogs

3. your markup us causing more than one of a listing per loop, as in you are using your markup twice or more within the for loop. If you have more than 10 blogs total than I would bet it is your markup.

Problem solved, I was using

<div class="widget-span widget-type-email_body " style="" data-widget-type="email_body">
{% content_attribute "email_body" %}{% end_content_attribute %}
 </div>

Which brings in HubSpot’s native blog subscription settings, causing the loop to duplicate. Removing that from the HTML and adding

{% rich_text "rich_text" %}

Solved the problem.

Anyway to limit posts on a rolling published date filter (i.e. the previous 7 days), as to not send repeat content?