CMS Development

spsangeeta
Member

Merging blog lists

SOLVE

Hi,

 

I have different blog templates for English and Arabic. I want to create a template which shows a list of blogs from both of English and Arabic blog pages sorted by date.

 

I tried to make changes in the post listing in the template, as shown on this page:

https://designers.hubspot.com/docs/tutorials/combining-multiple-sets-of-blog-posts-into-a-single-lis...

 

Below is my page link:

https://www.sabaconsultants.com/all-blogs

 

The page was created but the blog list doesn't show up.

 

I want to merge the blog list of the 2 pages below:

https://www.sabaconsultants.com/blog

https://www.sabaconsultants.com/blog-ar

 

Thanks in advance for your help!

 

 

0 Upvotes
1 Accepted solution
valerajoey
Solution
Participant | Platinum Partner
Participant | Platinum Partner

Merging blog lists

SOLVE
3 Replies 3
valerajoey
Solution
Participant | Platinum Partner
Participant | Platinum Partner

Merging blog lists

SOLVE

you can have some idea here https://community.hubspot.com/t5/Content-Design-Questions/Combine-multiple-blogs-in-Related-Posts/m-... and just sort it out by publish date 

best of luck
joey

ChadP
Contributor | Elite Partner
Contributor | Elite Partner

Merging blog lists

SOLVE

Is it possible you post the code you are using to combine the two lists?

 

spsangeeta
Member

Merging blog lists

SOLVE

 

{% set blog_one_posts = blog_recent_posts('5269069498', limit=5) %} <!-- sets a variable for a the 5 most recent posts of my default COS blog -->
{% set blog_two_posts = blog_recent_posts('5213662779', limit=5) %} <!-- sets a variable for a the 5 most recent posts of my blog id 47082700. You can find the blog id in the URL of the blog dashboard for a particular blog-->
{% set all_posts = (blog_one_posts + blog_two_posts) | sort(true, false, 'publish_date') %} <!-- combines the two variables into a single variable and sorts them by publish date. Please note the sort filter requires all three parameters -->
{% for post in all_posts %} <!-- loop through posts in custom all posts variable -->
<div class="post-item">
{% if not simple_list_page %}
<div class="post-header">
<h2><a href="{{post.absolute_url}}">{{ post.name }}</a></h2>
<div id="hubspot-author_data" class="hubspot-editable" data-hubspot-form-id="author_data" data-hubspot-name="Blog Author">
Posted by
{%if post.blog_post_author %}
<a class="author-link" href=" {{ post.parent_blog.absolute_url }}/author/{{ post.blog_post_author.slug }}">{{ post.blog_post_author.display_name }}</a> on {{ post.publish_date_localized }}
{% endif %}
</div>
{% blog_social_sharing "blog_social_sharing" overrideable=False, label='Blog Social Sharing' %}
</div>
<div class="post-body clearfix">
<!--post summary-->
{% if post.post_list_summary_featured_image %}
<div class="hs-featured-image-wrapper">
<a href="{{post.absolute_url}}" title="" class="hs-featured-image-link">
<img src="{{ post.post_list_summary_featured_image }}" class="hs-featured-image">
</a>
</div>
{% endif %}
{{ post.post_list_content|safe }}
</div>
{% if content_group.show_summary_in_listing %}
<a class="more-link" href="{{ post.absolute_url }}">Read More</a>
{% endif %}
<div class="custom_listing_comments">
{% set comments_number = post.comment_list|length %}
{% set comments_label = "Comment" if comments_number == 1 else "Comments" %}
{{ comments_number }} {{ comments_label }} <a href="{{post.absolute_url}}#comments-listing">Click here to read/write comments</a>
</div>
{% if post.topic_list %}
<p id="hubspot-topic_data"> Topics:
{% for topic in post.topic_list %}
<a class="topic-link" href=" {{ post.parent_blog.absolute_url }}/topic/{{ topic.slug }}</a>{% if not loop.last %},{% endif %}
{% endfor %}
</p>
{% endif %}
{% else %}
<h2 class="post-listing-simple"><a href="{{post.absolute_url}}">{{ post.name }}</a></h2>
{% endif %}
</div>
{% endfor %}

 

 

 

0 Upvotes