Get only published pages

March 24, 2011 EPiServer Troubleshooting Snippet
Just getting the children for a page in EPiServer CMS 5/6 will return all pages, even unpublished ones. Since you might not want this behaviour there's a way to filter out all the published (or unpublished - if that's your cup of tea) using FilterPublished:

using EPiServer.Filters;

....

PageDataCollection myPages = GetChildren(myParentPage);
new FilterPublished(PagePublishedStatus.Published).Filter(myPages);

Related posts: