Try Now
More in this section

Forums / Bugs & Issues / Using App.WorkWith to get blogPosts

Using App.WorkWith to get blogPosts

2 posts, 0 answered
  1. Richard
    Richard avatar
    103 posts
    04 Apr 2013
    30 Jul 2014
    Link to this post

    I'm attempting to get blogPosts... this part works. I attempt to get blog posts that are published... this also works. But then I attempt to get blogPosts and exclude posts that are expired, and this fails. The only way i can get posts that are published and not expired is to use the 'unpublish' setting for a post. I checked the database and there are 2 fields for expiredDate. Also, I was going to get posts that are before an unpublished date but there is no method for this. 

    var blogList = App.WorkWith().Blog(blogId).BlogPosts()
                    .Where(b => b.Status == ContentLifecycleStatus.Live && b.PublicationDate <= dateTimeNow                     && (b.ExpirationDate >= dateTimeNow || b.ExpirationDate.Equals(null)))
    var posts = from p in App.WorkWith().BlogPosts()
                            where p.Parent.Title == "Testing"
                            && (p.ExpirationDate >= dateTimeNow || p.ExpirationDate == null)
                            orderby p.Title
                            select p;

    Is the WorkWith fluent method properly wired to use expired field? I'm asking because I can't seem to find an unpublished attribute. 

  2. Sabrie Nedzhip
    Sabrie Nedzhip avatar
    534 posts
    26 Oct 2016
    04 Aug 2014
    Link to this post
    Hi Richard,

    Can you please try to use the Published() filter available for the fluent API, for example:


    The code above will retrieve all the blog posts which are published, visible on the frontend and their ExpirationDate equals to null or is set for a date after DateTime.Now.

    You may also take a look at the following forum post from more details on this matter.

    I hope this information helps. Please let me know if you need any further assistance.

    Sabrie Nedzhip
    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 Sitefinity CMS Ideas&Feedback Portal and vote to affect the priority of the items
2 posts, 0 answered