I need to publish a specific version of item to be published programmatically. Let's say I have item AboutUs which workflow enabled and have a total of 15 versions. The 10th version is already in final state and the rest are draft state. Then I add version 10 to my custom scheduled publishing task.

When the task is triggered and published successfully, it is the latest version published, even still in draft state.

Here's my current code:

PublishOptions publishOptions = new PublishOptions(sourceDb, targetDb, PublishMode.Smart, LanguageManager.DefaultLanguage, DateTime.Now);
publishOptions.Deep = isDeepPublish;
publishOptions.RepublishAll = false;
publishOptions.RootItem = itemToPublish; 
Publisher publisher = new Publisher(publishOptions);

When debugging, itemToPublish.Version returned version 10, which is the correct one.

I've also tried with :

PublishManager.PublishItem(itemToPublish, new Database[] { targetDb }, targetDb.Languages, isDeepPublish, false);

Yes, it works to publish the correct version, but somehow I got weirdness. Sometimes it would unpublish, sometimes field values are empty, sometimes not working at all. Also, it's not immediately published.

I'm using Sitecore 8.2 Initial Release

1 Answer 1


Publishing is not done on version level but on item level. Sitecore decides in a few pipelines which version will get published. By default that would be the latest version that is publishable (based on workflow and restrictions) and other versions that are needed for content tests.

There is a publishVersion pipeline: https://community.sitecore.net/technical_blogs/b/sitecore_development_team/posts/multiple-item-versions-in-web-database

And also the publishItem pipeline.

If you want to tweak the default behavior you should check to hook into one of those pipelines, but I actually think your issue might not be the publish itself but rather the status of the item when publishing.

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.