skip to Main Content

I have multiple blogs on my Shopify site. I’m trying to display posts from ALL blogs on the site in the featured section on the homepage. However, when I attempt to select them in the admin area, it only allows me to select one at a time.

What do I need to put in the {% schema %} (or template code) to allow me to select more than one blog in the theme’s admin area, thus displaying posts from more than one blog in featured section in the template?

enter image description here

Here is my current {% schema %}:

{% schema %}
{
  "name": "Blog posts",
  "class": "index-section",
  "settings": [
    {
      "type": "text",
      "id": "title",
      "label": "Heading",
      "default": "Blog posts"
    },
    {
      "id": "blog",
      "type": "blog",
      "label": "Blog"
    },
    {
      "type": "range",
      "id": "post_limit",
      "label": "Posts",
      "min": 3,
      "max": 12,
      "step": 3,
      "default": 3
    },
    {
      "type": "checkbox",
      "id": "blog_show_author",
      "label": "Show author",
      "default": false
    },
    {
      "type": "checkbox",
      "id": "blog_show_date",
      "label": "Show date",
      "default": true
    },
    {
      "type": "checkbox",
      "id": "show_view_all",
      "label": "Show 'View all' button",
      "default": false
    }
  ],
  "presets": [
    {
      "name": "Blog posts",
      "category": "Blog",
      "settings": {
        "blog": "News",
        "post_limit": 3
      }
    }
  ]
}
{% endschema %}

2

Answers


  1. Have you tried the simplest of Liquid constructions like:

    {% for blog in blogs %}
      <p>I am blog {{ blog.title }}</p>
    {% endfor %}

    That kind of thing? If you have many blogs, I would start with that. If you cannot iterate your existing blogs, you have no hope of showing off their contents in a section of your store, whatever that may be.

    Login or Signup to reply.
  2. Could you try this? Just add some more block schema

        
    <div class = "blog-container">
    
        {% if section.settings.blog != blank %}
        {% for blog in section.settings.blog %}
         
         <p>{{blog.title}}</p>
    
        {% endfor %}
    
    {% endif %}
    
    {% if section.settings.blogone != blank %}
     {% for blog in section.settings.blogone %}
         
         <p>{{blog.title}}</p>
    
    {% endfor %}
    
    {% endif %}
    
    
    {% if section.settings.blogtwo != blank %}
     {% for blog in section.settings.blogtwo %}
         
         <p>{{blog.title}}</p>
    
      {% endfor %}
    {% endif % }
         </div> 
    
     {% schema %}
    {
      "name": "Blog posts",
      "class": "index-section",
      "settings": [
        {
          "type": "text",
          "id": "title",
          "label": "Heading",
          "default": "Blog posts"
        },
        {
          "id": "blog",
          "type": "blog",
          "label": "Blog"
        },
     {
          "id": "blogtwo",
          "type": "blog",
          "label": "Blog Two"
        },
     {
          "id": "blogthree",
          "type": "blog",
          "label": "Blog Three"
        },
        {
          "type": "range",
          "id": "post_limit",
          "label": "Posts",
          "min": 3,
          "max": 12,
          "step": 3,
          "default": 3
        },
        {
          "type": "checkbox",
          "id": "blog_show_author",
          "label": "Show author",
          "default": false
        },
        {
          "type": "checkbox",
          "id": "blog_show_date",
          "label": "Show date",
          "default": true
        },
        {
          "type": "checkbox",
          "id": "show_view_all",
          "label": "Show 'View all' button",
          "default": false
        }
      ],
      "presets": [
        {
          "name": "Blog posts",
          "category": "Blog",
          "settings": {
            "blog": "News",
            "post_limit": 3
          }
        }
      ]
    }
    {% endschema %}
    
    
    
    
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search