CMS Development

MRF
Participant

Featured Image on Latest Post only!

Hello,

I want to show the featured image of my latest post in the hubspot RSS feed like the hubspot blog page (blog.hubspot.com). I don't want to show the featured image of every blog post as it gets to crowded.

 

Could you help me?

 

Thanks.

0 Upvotes
5 Replies 5
Jsum
Key Advisor

Featured Image on Latest Post only!

@MRF You can use HubL to create the rss module (if your using the drag and drop builder place in a HubL module):

{% set posts = blog_recent_posts('default', 5) %}
{% for post in posts %}
    
{% endfor %}

Then just target the first post in the loop using and if else statement:

{% set posts = blog_recent_posts('default', 5) %}
{% for post in posts %}
    {% if loop.index = 1 %}
{# markup for the first post #}
{% else %}
{# markup for the rest of the posts #}
{% endif %} {% endfor %}

If you want to do this for your main blog its the same concept just in the contents loop default to the hubspot blog. The only real difference between the first and the rest of the posts markup is that you would use the image tolken for the first but not the rest.

0 Upvotes
MRF
Participant

Featured Image on Latest Post only!

Thanks for this.

Could you explain where I would put those HubL codes?

 

Here is what my modules look like. As you can see, I have 4 blogs.

Hubspot Modules.JPG

 

Here is the blog homepage where I want it to show up.

http://blog.enduraplas.com/

 

Thanks.

0 Upvotes
Jsum
Key Advisor

Featured Image on Latest Post only!

Replace your rss modules with with hubl modules.

Place the code in the hubl modules.

Replace "default" found in the code for the id of the blog that will be found in the url for each blog.
0 Upvotes
MRF
Participant

Featured Image on Latest Post only!

Would it look like this?

HubL Sample.JPG

Also, where do I find the blog ID?

0 Upvotes
Jsum
Key Advisor

Featured Image on Latest Post only!

@MRF yes it will look like that. 

 

the {# #} in my code are comments that will not effect the code and can be removed. I placed them their to mark where you should place your markup. 

 

What you probably should do is create your markup using static content to create the structure and styling. Then when you have your markup created, integrate this hubl to fit around/inside/through it what ever the case may be. 

 

You find the blog id by going to blogs in your portal, choosing the blog you are working with, and their will be a set of, I beleive, 8 numbers in the url in your portal (not on the live blog page). This set of numbers is your blog id. 

0 Upvotes