I was looking for an answer and came across this comment which doesn't seem to work in Epi 11 anymore: https://world.episerver.com/forum/legacy-forums/Episerver-7-CMS/Thread-Container/2013/11/How-to-work-with-publish-date-on-a-page/#80995
I'm finding that if you previously publish a page, you can't go back and set the scheduled publish because the page will always show on the site. The only option is to expire the content so it doesn't show on the site, but now you can't schedule the publish because of the error "Expiration date cannot be prior to the published date." It will require a manual publish in the future to remove the expiration and live publish the content.
Steps to reproduce:
I have the following code in place to hopefully catch unpublished content, but once it's published it always has a publish date. It's based on https://www.jondjones.com/learn-episerver-cms/episerver-developers-tutorials/episerver-api-explained/how-to-check-if-an-episerver-page-is-published-or-not/
return allItems.Where(x => !x.IsDeleted && _publishState.Service.IsPublished(x, PagePublishedStatus.Published));
How can I get the content to not show when it is scheduled for publish regardless if it was previously published or not?
I came across this post as I experienced the same problem. I have raised it with Optimizely Support, with link to your observations.
Support mentioned that the feature is by design. Here are the steps to fix this:
Hi Nick, Stefan
I just encountered a similar scenario and while trying to understand how the Published property change on a page actually works, this is what i found : If you have a page already published and you go in and change the Published property to a future date and Publish again, now you would see a yellow bar on top indicating the publishing change and if you try browsing the page now, it throws 404, even though it was previously published. And this change doesn't need any job to publish the page. It will auto publish at the specified date time.
Which now brings me to a question : why would anyone use Schedule for Publish option and wait for a job to publish content when an automatic future publishing can be achieved by modifying the Published date property on page? Thoughts?