1

On the following screenshot the image on the right called Crown Wood - Plot 1 is disabled in the CMS, so I'd like it not to show up in the results.

Below is my code. I added .status('live') to the for loop as suggested elsewhere in the forum but the disabled posts are still showing up.

Can someone help, as I only want the section to show live entries.

enter image description here

{% set var = craft.entries.positionedAfter(entry).level('2') %}
{% for entry in var.limit('5').status('live') %}
<div class="related-carousel-cell">
  <div class="property">
    <a href="{{ entry.url }}">
      <div class="wrap">
      {% if entry.plotGallery.first() %}
        <img src="{{ entry.plotGallery.first().getUrl('relatedArticlesLarge') }}" class="property-image img-responsive" alt="{{ entry.title }}">
      {% endif %}
      </div>
      <div class="text">
        <h2>{{ entry.parent ? entry.parent.title }} - <span style="white-space: nowrap;">{{ entry.title }}</span></h2>
      </div>
    </a>
  </div>
</div>
{% endfor %}
2
  • 1
    I some sort of Caching at play here?
    – KSPR
    Commented Jan 17, 2017 at 11:14
  • I've already tried clearing the cache and have cache killer plugin on the browser active
    – mention79
    Commented Jan 17, 2017 at 11:16

1 Answer 1

2

The code is correct, it was that I hadn't disabled the individual entries in the CMS, I'd only disabled the parent in the structure.

So adding .status('live') on the end of the for loop is the solution, and making sure every entry at all levels is disabled.

1
  • 4
    .status('live') shouldn’t be required as it is the default for the status param anyway.
    – carlcs
    Commented Jan 17, 2017 at 11:33

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.