{% for content in contents %} {# fetch all blog posts #}
{% if loop.index >= 1 %} {# exclude first blog post #}
{# YOUR CONTENT GOES HERE #}
{% endif %}
{% endfor %}
I would say that it depends how you're building your pagination. I've wrote mine like this and it works flawlessly with the code above:
{% if not simple_list_page %}
<div class="row-fluid-wrapper">
<div class="row-fluid">
<div class="span12 col-12">
<div class="pagination">
{% if contents.total_page_count > 1 %}
<div class="blog-pagination">
{% set page_list = [-2, -1, 0, 1, 2] %}
{% if contents.total_page_count - current_page_num == 1 %}{% set offset = -1 %}
{% elif contents.total_page_count - current_page_num == 0 %}{% set offset = -2 %}
{% elif current_page_num == 2 %}{% set offset = 1 %}
{% elif current_page_num == 1 %}{% set offset = 2 %}
{% else %}{% set offset = 0 %}{% endif %}
<a class="pagination-prev {{ "blog-pagination__prev-link--disabled" if !last_page_num }}" href="{{ blog_page_link(last_page_num) }}">
<i class="fas fa-chevron-left"></i>
</a>
{% for page in page_list %}
{% set this_page = current_page_num + page + offset %}
{% if this_page > 0 and this_page <= contents.total_page_count %}
<a class="pagination-active {{ "me-blog-pagination__page--active" if this_page == current_page_num }}" href="{{ blog_page_link(this_page) }}">{{ this_page }}</a>
{% endif %}
{% endfor %}
<a class="pagination-next {{ "blog-pagination__next-link--disabled" if !next_page_num }}" href="{{ blog_page_link(current_page_num + 1) }}">
<i class="fas fa-chevron-right"></i>
</a>
</div>
{% endif %}
</div>
</div>
</div>
</div>
{% endif %}
when using {% if not loop.first %} could work too. To be honest never tried that. You could also write {% unless loop.first %}everything except the first post{% else %}first post{% endunless %}. Depends on how you want to build your logic but has the same result.
{% for content in contents %} {# fetch all blog posts #}
{% if loop.index >= 1 %} {# exclude first blog post #}
{# YOUR CONTENT GOES HERE #}
{% endif %}
{% endfor %}
I would say that it depends how you're building your pagination. I've wrote mine like this and it works flawlessly with the code above:
{% if not simple_list_page %}
<div class="row-fluid-wrapper">
<div class="row-fluid">
<div class="span12 col-12">
<div class="pagination">
{% if contents.total_page_count > 1 %}
<div class="blog-pagination">
{% set page_list = [-2, -1, 0, 1, 2] %}
{% if contents.total_page_count - current_page_num == 1 %}{% set offset = -1 %}
{% elif contents.total_page_count - current_page_num == 0 %}{% set offset = -2 %}
{% elif current_page_num == 2 %}{% set offset = 1 %}
{% elif current_page_num == 1 %}{% set offset = 2 %}
{% else %}{% set offset = 0 %}{% endif %}
<a class="pagination-prev {{ "blog-pagination__prev-link--disabled" if !last_page_num }}" href="{{ blog_page_link(last_page_num) }}">
<i class="fas fa-chevron-left"></i>
</a>
{% for page in page_list %}
{% set this_page = current_page_num + page + offset %}
{% if this_page > 0 and this_page <= contents.total_page_count %}
<a class="pagination-active {{ "me-blog-pagination__page--active" if this_page == current_page_num }}" href="{{ blog_page_link(this_page) }}">{{ this_page }}</a>
{% endif %}
{% endfor %}
<a class="pagination-next {{ "blog-pagination__next-link--disabled" if !next_page_num }}" href="{{ blog_page_link(current_page_num + 1) }}">
<i class="fas fa-chevron-right"></i>
</a>
</div>
{% endif %}
</div>
</div>
</div>
</div>
{% endif %}
when using {% if not loop.first %} could work too. To be honest never tried that. You could also write {% unless loop.first %}everything except the first post{% else %}first post{% endunless %}. Depends on how you want to build your logic but has the same result.
That looks a lot like the code we use as well. I've had some issues with the posts per page and showing a nice grid, had to fill in the empty space with a CTA block.
I'll check for differences between your code and mine to see why yours is working.
Learn more about HubSpot by following me on LinkedIn or YouTube
✅ Did my answer solve your issue? Help the community by marking it as the solution.
As the amount of posts shown per page is defined in the HubSpot blog settings, I did not find a workaround. You could however, display an extra CTA (like the form CTA you have available) on the first page to make sure that you are not missing one card in your grid (so replace the first post with an CTA, but change its position).
If you only show this on the first page and exclude the first post with the if statement you allready have (or using if not loop.first), you should have a working blog listing.
Learn more about HubSpot by following me on LinkedIn or YouTube
✅ Did my answer solve your issue? Help the community by marking it as the solution.