I'm the new to Umbraco and I'm struggling to get the unpublished contents.
I have created a document type article and article items as mentioned in our Umbraco tutorial. In content section I have created a five number of article items as a blog and unpublished two of them. I'm getting three published article items in the site. Now I want to get the unpublished contents instead of published one. How I can do this?
You can use the ContentService to get your unpublished content, but be very careful when using the ContentService as this service directly gets the data from the Umbraco database rather than the cache and this will cause a lot of problems on your site, like the website being very slow, especially if a lot of people are reaching to your website.
Here is an example to use the ContentService, You can take a look at this blog post for more details.
Here is another example;
For the latest version of Umbraco (v9 as of today), you should use Dependency Injection in your constructor to get the ContentService:
Update: Today I have had a chance to add some screenshots for an Umbraco v7 project, please see below how you can get the unpublished content via the ContentService - things could be a little different for an Umbraco v8 project: