2

I'm trying to figure out the best way to create an entry that is live but "unlisted". I know wordpress has the option, and the same thing you can do when uploading videos to youtube.

What's the best way to have a post be live but not included into the regular posts returned when listing items?

1
  • 2
    Can't tell if I'm underthinking or you're overthinking... but wouldn't a simple lightswitch handle this pretty well?
    – Lindsey D
    Jul 13 '17 at 20:48
3

If you create a Lightswitch field and add it to the section's field layout (let's call it unlisted), then you can query for live entries that have unlisted not checked with:

{% set entries = craft.entries.section('sectionHandle').unlisted('not 1').find() %}

{% for entry in entries %}
    ...
{% endfor %}
1
  • Awesome, perfectly what I was looking for. Thank you! Jul 14 '17 at 13:24
1

You could add a lightswitch field as mentioned above, but it seems to me you could just use Craft's built-in Enabled status, no?

Enabled

I do this all the time for blog entries while I'm working on them, so that they are there, but they don't appear in the listings. The bonus is that you don't have to change anything from a templating POV, entries that aren't enabled don't show up by default in craft.entries

Second bonus is that you can use the Share link (the arrow next to Live Preview) so share a tokenized URL with others that they can view before the entry is live on the website.

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.