CMS Development

suyen-rojas
Member

Get Recent and Popular Posts Based on Language

SOLVE

Hi everybody,

My team is creating the Spanish version of our website(currently in english only). 
I am using the multilanguage feature in husbpot, so I am creating all the pages groups with that.
My problem now is: I need to show the 5 most recent/popular posts of the blog in some of the pages, I am using the hubl functions blog_recent_posts('###', 5) and blog_popular_posts('##', 5).

How can I use those functions or any other, to get the top 5 corresponding to the language? Since the Blog id still the same in both laguages I haven't find a way to do that.

Any idea? Workaround? 

Thanks!

0 Upvotes
1 Accepted solution
Gonzalo
Solution
Top Contributor | Partner
Top Contributor | Partner

Get Recent and Popular Posts Based on Language

SOLVE

I suggest you to double check your setup, the ideal one would be to split the blog based on language, you will probably have some other issues on your HTML marktup regarding the multilingual setup, and if you are translating the posts you won't get auto-relation for canonical links.

 

Said that, for the current setup (not ideal) from the top of my mind I can think on using the `blog_popular_posts()` with a higher limit (if you use to translate most of your post 15 should be enough, otherwise you could go up to 20-30 to be safe).
Then you can loop the posts trying to filter by the language and displaying the most popular in one language only. Although I am not completely sure this can be done, because I believe the language setting cames from the blog itself and not from the post? But Hubspot added multilingual recently to the blog so I didn't had the time to double check about it.
While in a blog post use the developer info link to get the available variables to find something related to the language.

If this answer helps you to solve your questions please mark it as a solution.

Thank you,


Gonzalo Torreras

HubSpot freelance developer

hola@gonzalotorreras.com
www.gonzalotorreras.com
Schedule a meeting

View solution in original post

2 Replies 2
Gonzalo
Solution
Top Contributor | Partner
Top Contributor | Partner

Get Recent and Popular Posts Based on Language

SOLVE

I suggest you to double check your setup, the ideal one would be to split the blog based on language, you will probably have some other issues on your HTML marktup regarding the multilingual setup, and if you are translating the posts you won't get auto-relation for canonical links.

 

Said that, for the current setup (not ideal) from the top of my mind I can think on using the `blog_popular_posts()` with a higher limit (if you use to translate most of your post 15 should be enough, otherwise you could go up to 20-30 to be safe).
Then you can loop the posts trying to filter by the language and displaying the most popular in one language only. Although I am not completely sure this can be done, because I believe the language setting cames from the blog itself and not from the post? But Hubspot added multilingual recently to the blog so I didn't had the time to double check about it.
While in a blog post use the developer info link to get the available variables to find something related to the language.

If this answer helps you to solve your questions please mark it as a solution.

Thank you,


Gonzalo Torreras

HubSpot freelance developer

hola@gonzalotorreras.com
www.gonzalotorreras.com
Schedule a meeting
dennisedson
HubSpot Product Team
HubSpot Product Team

Get Recent and Popular Posts Based on Language

SOLVE

@Gonzalo , @Anton  do either of you have advice for @suyen-rojas ?

Thanks,

Dennis




HubSpot Community Developer ShowMake sure to subscribe to our YouTube channel
where you can find the HubSpot Community Developer Show
0 Upvotes