{% if posts or title or text %}
  {% set archiveLink = fn.get_post_type_archive_link('campaigns') %}
  <section class="m_campaign m_panel" m-pack="premium">
    {% if posts %}
      <div class="flex">
        {% for post in posts %}

          {% set tax = fn.wp_get_post_terms(post.ID, 'category', {'fields': 'names'}) %}

          {% set post_title = post.post_title %}
          {% set post_text = post.post_content %}
          {% set post_date = post.post_date | date('d. m. y') %}
          {% set dateTime = post.post_date|date('Y-m-d') %}

          {% set post_link = fn.get_the_permalink(post.ID) %}

          {% set postThumbM = fn.get_the_post_thumbnail_url(post.ID, 'medium') %}
          {% set postThumbS = fn.get_the_post_thumbnail_url(post.ID, 'thumbnail') %}

          {% if loop.last %}
            <div class="m_campaign__sub active">
          {% else %}
            <div class="m_campaign__sub">
          {% endif %}
            <div class="m_campaign__block">
              <div class="m_campaign__image">
                {% if post.video_news %}
                  <span class="m_video__player"></span>{% endif %}
                <picture class="objectfit--cover">
                  <source media="(min-width: 786px)" lazy-src="{{postThumbM}}">
                  <source media="(min-width: 320px)" lazy-src="{{postThumbS}}">
                  <img lazy-src="{{postThumbM}}" alt="{{postTitle}}">
                </picture>
              </div>

              <div class="m_campaign__content">
                <h3>{{post_title}}</h3>
                {% if post_text %}
                  <p>{{post_text|striptags}}</p>
                {% endif %}
              </div>
            </div>
            <a href="{{post_link}}" class="btn btn__primary">Voir plus</a>
          </div>
        {% endfor %}

        <button class="left">
          <svg width="23px" height="40px" viewBox="0 0 23 40" version="1.1" xmlns="http://www.w3.org/2000/svg">
            <g id="Page-1" stroke="none" stroke-width="1" fill="none" fill-rule="evenodd">
                <path d="M22.1724913,21.9802057 L4.82338359,39.1790363 C3.71977078,40.2736546 1.93045178,40.2736546 0.827374747,39.1790363 C-0.275791582,38.0853917 -0.275791582,36.3116055 0.827374747,35.2180495 L16.1786566,19.9997123 L0.827821229,4.78190626 C-0.275345101,3.68781911 -0.275345101,1.9142099 0.827821229,0.820565368 C1.93098756,-0.273521789 3.72021726,-0.273521789 4.82383007,0.820565368 L22.1729378,18.0196615 C22.724521,18.5667494 23,19.2830095 23,19.9996238 C23,20.7165921 22.7239852,21.4333834 22.1724913,21.9802057 Z" id="Path" fill="#000000" transform="translate(11.500000, 20.000000) scale(-1, 1) translate(-11.500000, -20.000000) "></path>
            </g>
          </svg>
        </button>
        <button class="right">
          <svg width="23px" height="40px" viewBox="0 0 23 40" version="1.1" xmlns="http://www.w3.org/2000/svg">
            <g stroke="none" stroke-width="1" fill="none" fill-rule="evenodd">
                <path d="M22.1724913,21.9802057 L4.82338359,39.1790363 C3.71977078,40.2736546 1.93045178,40.2736546 0.827374747,39.1790363 C-0.275791582,38.0853917 -0.275791582,36.3116055 0.827374747,35.2180495 L16.1786566,19.9997123 L0.827821229,4.78190626 C-0.275345101,3.68781911 -0.275345101,1.9142099 0.827821229,0.820565368 C1.93098756,-0.273521789 3.72021726,-0.273521789 4.82383007,0.820565368 L22.1729378,18.0196615 C22.724521,18.5667494 23,19.2830095 23,19.9996238 C23,20.7165921 22.7239852,21.4333834 22.1724913,21.9802057 Z" id="Path" fill="#000000"></path>
            </g>
          </svg>
        </button>
      </div>

    {% endif %}
  </section>
{% endif %}
