Liquid Iterate Through All Articles in All Blogs

Shopify Partner
165 34 61

You need to create a link list and then in the items you need to add all the blogs 

Problem Solved? ✔️Accept the solution so you can help others.
* Email: fayyazraza@gmail.com * Skype: fayyaz_raza
0 Likes
Tourist
9 0 0

Ok, so I think I've figured it out...

 

I created a menu in the navigation section with the blogs I want - that menu gives me a handle - so now I use that handle for my linklist? 

0 Likes
Shopify Partner
165 34 61

Exactly 

Problem Solved? ✔️Accept the solution so you can help others.
* Email: fayyazraza@gmail.com * Skype: fayyaz_raza
Tourist
9 0 0

Great - thanks for that!

0 Likes
Shopify Partner
165 34 61

Please accept the solution and like my solution. Thanks

Problem Solved? ✔️Accept the solution so you can help others.
* Email: fayyazraza@gmail.com * Skype: fayyaz_raza
Tourist
9 0 0

Thanks mate, I've liked your answer but I can't mark it as a solution since I didn't start the thread :(

0 Likes
Shopify Partner
10 0 4

@Fayyaz_Ahmed wrote:
{% for blog in blogs %}
  {% for article in blog.articles %}
    {{ article.title }}
  {% endfor %} 
{% endfor %}

I'm trying to do the same thing, and this is not working for me (copy/pasted your code into my template files) at all. Even just looping through blogs and printing the handle or title is not working. Does anyone know if Shopify has made changes in the last few months that would affect this? I don't see anything in the changelog.

 

Thanks.

0 Likes
Tourist
3 0 1

@Ryan_Kelly wrote:

@Fayyaz_Ahmed wrote:
{% for blog in blogs %}
  {% for article in blog.articles %}
    {{ article.title }}
  {% endfor %} 
{% endfor %}

I'm trying to do the same thing, and this is not working for me (copy/pasted your code into my template files) at all. Even just looping through blogs and printing the handle or title is not working. Does anyone know if Shopify has made changes in the last few months that would affect this? I don't see anything in the changelog.

 

Thanks.


You have to be on the blog page. Your url must look like this: <store_url>/blogs/some-blog-handle. And not like this: <store_url>/pages/some-page

0 Likes
New Member
1 0 0

Hi,

 

I am trying to do something similar. We have a total of 5 blogs: Reviews, News, HowTo, Beginners and Products. On the home page of the site I would like the most recent 3 published articles across any of the blogs - whichever is most recent. 

The following is giving me 3 articles form the first blog - can you help?

 

     {% for l in linklists.blogs.links %}
  {% assign b = l.object %}
  {% for a in b.articles  %}
    {% if j < 3 %}
{% assign j = j | plus: 1 %}     
                {%
                  include 'article-excerpt',
                  article: a
                %}
      {% endif %}
 
  {% endfor %} 
{% endfor %}
     

 

 

0 Likes
Tourist
3 0 1

Hi GursoyGalip,

 

You will need two `for` loops in this situation. The first one is for the blogs and the second one is for the articles inside each blog. Here's how it would look:

 

{% assign my_blogs = "reviews,news,howto,beginners,products" | split: "," %}

{% for blog_handle in my_blogs %}
    {% assign this_blog = blogs[blog_handle] %}
    {% for article in this_blog.articles | limit: 3 %}
        {% include 'article-excerpt' %}
    {% endfor %}
{% endfor %}
0 Likes