This project is read-only.

New Post Count for a Category

May 31, 2011 at 2:32 PM

Ultimately what I am looking to do here is take the count of posts that are less then 24 hours old and are listed with the Category of News and get the count of those only.

at the top of my site I have a link for the News Category which I will be adding a literal next to the name of the category that will display the amount of new posts for the news category.

This obviously would happen in the master file hopefully someone can guide me in the correct direction on this one.

May 31, 2011 at 4:52 PM

To get the number of posts that match your criteria you can use the api with a little bit of linq flavor.

                p => p.IsVisibleToPublic && p.DateCreated >= DateTime.Now.AddDays(-1));

just replace categoryid with the id (guid) of the category.

May 31, 2011 at 5:08 PM
I tried both ways shown here and it just scrambles the page it doesn't give a compile error or anything like that just scrambles the page to ascii
what is it that I am doing wrong here?
                p => p.IsVisibleToPublic && p.DateCreated >= DateTime.Now.AddDays(-1));

                p => p.IsVisibleToPublic && p.DateCreated >= DateTime.Now.AddDays(-1));


May 31, 2011 at 5:30 PM

Disregard my last comment I was not thinking of what it was I was doing. I have it working now