1-888-365-2779
+1-888-365-2779
Try Now
More in this section

Forums / Developing with Sitefinity / Fluent api returning blog posts in draft status?

Fluent api returning blog posts in draft status?

3 posts, 0 answered
  1. Jeff
    Jeff avatar
    118 posts
    Registered:
    08 Jul 2011
    21 Nov 2012
    Link to this post
    using (var fluent = App.WorkWith())
     {
                var list = fluent.BlogPosts()
                                .Where(b => b.Status == ContentLifecycleStatus.Live)
                                .Get().Take(5);
    }
    I'm using the following to return blog posts but posts that are still in draft status are being included. Is this a bug or am I not querying them correctly?

  2. Victor Velev
    Victor Velev avatar
    1345 posts
    Registered:
    06 Jul 2015
    21 Nov 2012
    Link to this post
    Hello Jeff,

    Can you try to set the .Visible attribute to true as well, so that the blog posts can be properly filtered - if you set the Visible attribute to true, you will notify the system to take items that are publicly visible. For example:

    var BlogPosts = App.WorkWith().BlogPosts().Where(p => p.Parent.Title == "blog2" && p.Status == ContentLifecycleStatus.Live && p.Visible == true).Get().ToList();

    The following query will return all published blog posts that are in the Blog called blog2. You can check the attached screenshot as well.

    All the best,
    Victor Velev
    the Telerik team
    Do you want to have your say in the Sitefinity development roadmap? Do you want to know when a feature you requested is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  3. Jeff
    Jeff avatar
    118 posts
    Registered:
    08 Jul 2011
    21 Nov 2012 in reply to Victor Velev
    Link to this post
    Thanks. That worked.
3 posts, 0 answered