How can I access a blog object by looping blocks in a blog?

How can I access a blog object by looping blocks in a blog?

vinodkalyan
Shopify Partner
10 0 1

i have created block of blog , that is input type=blog , how can i access blog object by looping blocks of blog

{% for block in section.blocks %}
{% assign blog = block.settings.blog %}
{{ blog | json }}

{% endfor %}
Reply 1 (1)

NomtechSolution
Astronaut
1245 113 159

To access the blog object within a loop of blocks in your Liquid code, you can use the following syntax:

{% for block in section.blocks %}
  {% assign blog = block.settings.blog %}
  {{ blog | json }}
{% endfor %}

In the above code, the block.settings.blog represents the blog object defined in each block's settings. By assigning it to the blog variable, you can then use {{ blog | json }} to output the JSON representation of the blog object.