How can I ignored archived content in IContentQueryExecutor?

I have the following code/query:

var builder = new ContentItemQueryBuilder()
	.ForContentType(
		ClientStoryDetail.CONTENT_TYPE_NAME,
		config => config
			.Where(where => where
				.WhereContainsTags(nameof(ClientStoryDetail.InternalStoryType), [diagnosedTag.Identifier])
				.Or()
				.WhereContainsTags(nameof(ClientStoryDetail.InternalStoryType), [caregiverTag.Identifier])
				.Or()
				.WhereContainsTags(nameof(ClientStoryDetail.InternalStoryType), [bereavedTag.Identifier])
			)
			.ForWebsite(contextHelper.CurrentSiteName, includeUrlPath: true)
			.WithLinkedItems(2));
			
var contentQueryExecutionOptions = new ContentQueryExecutionOptions()
{
	ForPreview = false
};

var webpageResult = await _contentQueryExecutor.GetMappedWebPageResult<ClientStoryDetail>(
	builder,
	options: contentQueryExecutionOptions);

In that, I would expect that webpageResult would not have any archived items since ForPreview = false, but it is returning archived items.

Is that by design or a bug? It seems a little clunky to add a line in the query about getting only Published versions of something when I'm also passing the ContentQueryExecutionOptions.

Environment

  • Xperience by Kentico version: [30.12.2]

  • .NET version: [8]

Answers

What do you mean by "archived items"? Xperience has the following content item states:

  • Initial Draft - there is no published version but there is a version being edited.
    ForPreview = true retrieves the draft, ForPreview = false retrieves nothing.

  • Draft - there is a published version, but the latest version is unpublished.
    ForPreview = true retrieves the draft, ForPreview = false retrieves the published version.

  • Published - the latest version is visible to visitors.
    ForPreview = true retrieves the published version, ForPreview = false retrieves the published version.

  • Unpublished - there was a published version, but the latest version is neither published nor being edited.
    ForPreview = true retrieves the unpublished item, ForPreview = false retrieves nothing.

You can also move items to the recycle bin, which moves them out of the Content hub or channel entirely and are unavailable to content querying. There is no built-in API to exclude unpublished items.

You can try filtering on CMS.ContentEngine.ContentItemLanguageMetadata.LatestVersionStatus where it doesn't equal VersionStatus.Unpublished.

Edit: Ah, I remembered the "archived" term was renamed "unpublished" in the December 2025 Refresh.

To response this discussion, you have to login first.