Thanks Zincorp,
I could sort post by published date. But I have more than 20 blogs in the intranet and I don’t have access in production server. And based on Zincorp’s solution I need to create new web parts for each blog or need to edit the parameter value, and it is not possible in my situation.
So I achieved this in another way.
First I crate a web part that reads the blog from current site.
string url = Request.Url.ToString();
SPSite site = new SPSite(url.Substring(0, url.LastIndexOf('/')));
And using the CAML query I could read & sort posts by published date.
The next task is to replace all the post data form web part with the new web part. For this I created a feature that fetch all the blogs in my site collection and replace the web part using below code
using (SPWeb spWebTest = spSiteTest.OpenWeb())
{
SPWebPartCollection webparts = spWebTest.GetWebPartCollection("default.aspx", Storage.Shared);
for (int k = 0; k < webparts.Count; k++)
{
//get reference to webpart
Microsoft.SharePoint.WebPartPages.WebPart wp = webparts[k];
//check webpart Title to find webpart which is to be removed
if (wp.Title == "Posts")
{
//delete webpart
webparts.Delete(wp.StorageKey);
//update spWeb object
spWebTest.Update();
} }
//create new webpart object
WebPartToBeAdded wpNew = new WebPartToBeAdded();
//set properties of new webpart object
wpNew.ZoneID = "1";
wpNew.Title = "LatestPost";
wpNew.ChromeState = System.Web.UI.WebControls.WebParts.PartChromeState.Normal;
wpNew.ChromeType = System.Web.UI.WebControls.WebParts.PartChromeType.None;
//add new webpart object to webparts collection
webparts.Add(wpNew);
}