Blog Object In "Pages"

Solved
New Member
3 0 1

Hi guys!

 

I have several different blog types and want to create a page that has the most recent blogs for all of these.  In creating a unique page from shopify's "pages" section, I'm trying to call blog objects so that I can pull in the most recent articles from 4 different blogs.

 

I'm the amateur of amateurs.  I understand coding to a degree, but not well enough to logically think this through myself, and the coding isn't responding like I expected.  Is it possible to call any of the blog objects from my unique page?  If so, what would the basic code look like?  If someone shows me how to display the most recent blog name, for example, I'd be able to think the rest through myself.

 

Thanks!

0 Likes
Highlighted

Success.

Shopify Partner
236 59 70

Hi @BroDownPro,

 

I understand that you want to access the Blog object from your custom page. The reason you're having trouble is that the Blog object is not accessible from page templates.

 

The workaround for this is to create a special linked-list for your blogs – and then target that linked-list to pull the Blog objects into your code:

 

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

  1. From your Shopify admin, go to Online Store > Navigation.
  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 %}
  2. Click Save.

 

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

Brian | Shopify Partner | Ecommerce Consultant
 - Was my reply helpful? Click Like to let me know! 
 - Was your question answered? Click Accept as Solution  
 - Need further assistance? Visit www.BrianAtWork.com

1 Like
New Member
3 0 1

Brilliant work-around and exactly what I needed.  Thank you so much.

1 Like