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 class="text">
        <h2>{{ entry.parent ? entry.parent.title }} - <span style="white-space: nowrap;">{{ entry.title }}</span></h2>
{% endfor %}
  • 1
    I some sort of Caching at play here? – KSPR Jan 17 '17 at 11:14
  • I've already tried clearing the cache and have cache killer plugin on the browser active – mention79 Jan 17 '17 at 11:16

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.

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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