How to display all BLOGS with different CATEGORIES in one page?

Cody917
Excursionist
14 0 8

Like product, I can show all product by doing Navigation > Add menu item > All collections

 

But I can't do >all categories for blogs, is there way to show all of the blogs in one page? 

 

Thank you so much for your help.

Replies 9 (9)

oscprofessional
Shopify Partner
15741 2354 3057

You will need to code it.

  • Go to Online Store ->Themes->Actions->Edit Code.
  • You should see multiple liquid files categorized, go under "Templates"->Choose "Add a new template"->Create a new template for 'Page' called 'all-blog'.

oscprofessional_0-1627284157879.png

 

Step 1

 

  • The page you just created will open in an editor. Copy and paste the below code just after the line {{ page.content }}. (Your page might have some different html content but this line will be present): 

Note: Here blog1 and blog2 and blog3 are your blog handles. Go to your respective blog pages and copy the part after the last '/'. Like: 

oscprofessional_1-1627284157529.png

 

 {% assign blog_handles = "blog1,blog2,blog3" | split: "," %}

   {% for handle in blog_handles %}
        {% for article in blogs[handle].articles %}
               <h2><a href="{{ article.url }}">{{ article.title }}</a></h2>
         {% endfor %}
{% endfor %}

 

oscprofessional_2-1627284157614.png

 

Step 2

  • Now, go to page -> Add new page -> Put title whatever you like, I put it 'Blog' -> Choose template suffix on the right side as 'page.all-blog'. Save it.

oscprofessional_3-1627284157768.png

 

Step 3

Go view the page you just created. It will display your article's heading and clicking them will take you to the articles. (Article is alias for blog posts in Shopify).  Read more article object properties here: https://shopify.dev/docs/themes/liquid/reference/objects/article 


Get pass your Store Core Web Vital Free Speed Optimization Audit, Chat on WhatsApp | Skype : oscprofessionals-87 | Email: pallavi@oscprofessionals.com | Custom Pricing Wholesale App : Free | Hire us | Guaranteed Site Speed Optimization | Website Free Audit | Shopify Theme Customization | Build Shopify Private App | Shopify SEO | Digital Marketing
Cody917
Excursionist
14 0 8

Thank you! It works but all the template is lost & no blog pic is showing, is there anyway to keep the template while showing all the blogs? @oscprofessional

oscprofessional
Shopify Partner
15741 2354 3057

Try this 

Step 1: Create the special "Blogs" linked-list:

  1. From your Shopify admin, go to 
  2. Click the Add menu button.
  3. Enter Blogs as the Title.
  4. Repeat the following for each blog category that you want listed:
    1. Click Add menu item.
    2. Click in the Link box and select Blogs from the pop-up menu.
    3. Select the Blog that you want displayed.
  5. Click Save menu.

Step 2: Edit your custom page template

  1. Add the following code to your custom page template:

 

 

{% for link in linklists.blogs.links %}
  {% assign blog = link.object %}
  {% for article in blog.articles %}
    <h2><a href="{{ article.url }}">{{ article.title }}</a></h2>
  {% endfor %} 
{% endfor %}

 

 

  1. Click Save.

Let me know if this solves your problem or if you need further help!

Get pass your Store Core Web Vital Free Speed Optimization Audit, Chat on WhatsApp | Skype : oscprofessionals-87 | Email: pallavi@oscprofessionals.com | Custom Pricing Wholesale App : Free | Hire us | Guaranteed Site Speed Optimization | Website Free Audit | Shopify Theme Customization | Build Shopify Private App | Shopify SEO | Digital Marketing
ConsciousEarth
Visitor
1 0 0

Hello! I followed your step 1 which worked and then had the same issue of no photos showing in the all blogs listing (https://oneconsciousearth.shop/pages/all-knowledge)

Attempted step 2 and it hasn't changed anything.

Is there another way or maybe more detailed instructions for step 2 (to make sure I am getting it right)?

 

adventmedia
Pathfinder
128 0 31

How do you do this in Dawn theme with json template?

Rajev
Shopify Partner
1 0 0

Hello @oscprofessional, thank you for the above solution which is working. Also could you please add a code on how we can implement the pagination and order of displaying the post based on the date for the above solution? 

 

Thank you

protohominid
Shopify Partner
3 0 0

Hey, this looks like it might work for what I want to do, but what about pagination? I can't have the page load 400+ items...

Saloni1
Tourist
7 0 1

Hello, I am using 'Taste' theme and unfortunately this solution does not work for that anymore. I have looked through the code and I cannot find {{ page.content }} anywhere in that code when a new template is created. Do you know something may have changed in the shopify templates over the last couple years? I am creating a store now and want to show all blog posts on the same page for customers to browse but unfortunately, I am unable to do so. Can you help please? Thanks! 

Yickxin
Visitor
1 0 0

That's also my question. Thank you