{% extends '@nucleus/partials/particle.html.twig' %} {% set attr_extra = particle.extra|attribute_array %} {% set post_settings = particle.post %} {% set filter = post_settings.filter %} {% set sort = post_settings.sort %} {% set limit = post_settings.limit %} {% set start = limit.start + max(0, ajax.start|int) %} {% set display = post_settings.display %} {# Sticky Posts #} {% set sticky_posts = filter.sticky ? false : true %} {# Query Posts #} {% set query_parameters = { 'posts_per_page': limit.total|default('-1'), 'offset': start, 'orderby': sort.orderby, 'order': sort.ordering, 'ignore_sticky_posts': sticky_posts } %} {% if filter.posts %} {% set query_parameters = query_parameters|merge({'post__in': filter.posts|replace({' ': ',', ', ': ','})|split(',')}) %} {% else %} {% set query_parameters = query_parameters|merge({'cat': filter.categories|replace({' ': ',', ', ': ','})}) %} {% endif %} {% set posts = wordpress.query_posts(query_parameters) %} {% set total = posts.get_pagination([]).total|abs %} {% set total = max(posts|length, (total * max(0, limit.total))) %} {% block particle %} {# All Posts #}
{% for column in posts|batch(limit.columns) %}
{% for post in column %}
{% if display.image.enabled and post.thumbnail.src %} {% endif %} {% if display.title.enabled %} {% endif %} {% if display.date.enabled or display.author.enabled or display.category.enabled or display.comments.enabled %}
{% if display.date.enabled %} {% if display.date.enabled == 'modified' %} {{ post.post_modified|date(display.date.format) }} {% else %} {{ post.post_date|date(display.date.format) }} {% endif %} {% endif %} {% if display.author.enabled %} {{ post.author.name|raw }} {% endif %} {% if display.category.enabled %} {% set category_link = display.category.enabled == 'link' %} {%- set post_categories -%} {% for category in post.categories %} {%- if category_link -%} {{ category.title|raw }} {%- else -%} {{ category.title|raw }} {%- endif -%} {% if not loop.last %}{{ ','|trim }}{% endif %} {% endfor %} {%- endset -%} {{ post_categories|raw }} {% endif %} {% if display.comments.enabled %} {%- set comment_count -%} {%- if post.comment_count == '0' -%} {{ __('No comments', 'gantry5') }} {%- elseif post.comment_count == '1' -%} {{ post.comment_count ~ ' ' ~ __('Comment', 'gantry5') }} {%- else -%} {{ post.comment_count ~ ' ' ~ __('Comments', 'gantry5') }} {%- endif -%} {%- endset -%} {{ comment_count }} {% endif %}
{% endif %} {% if display.text.type %} {% set post_text = display.text.type == 'excerpt' ? post.post_excerpt : post.content %}
{% if display.text.formatting == 'text' %} {{ post_text|truncate_text(display.text.limit)|raw }} {% else %} {{ post_text|truncate_html(display.text.limit)|raw }} {% endif %}
{% endif %} {% if display.read_more.enabled %} {% endif %}
{% endfor %}
{% endfor %} {% if total > limit.total and display.pagination_buttons %}
{% endif %}
{% endblock %} {% block javascript_footer %} {% if total > limit.total and display.pagination_buttons %} {% do gantry.load('jquery') %} {% endif %} {% endblock %}