This is a very basic post. I really couldn’t find any post that could tell me how to add “Recent Blog Posts” web part using object modal.
The “Recent Blog Posts” web part is added by default on the SharePoint 2010 My Sites. I was just wondering if we can add that using the SharePoint Object Modal.
I found out that adding a recent blog posts web part is really simple:-
// Get the web part collection
SPLimitedWebPartManager wpManager = web.GetLimitedWebPartManager(“default.aspx”, PersonalizationScope.Shared);
Microsoft.SharePoint.Portal.WebControls.BlogView wpBlogView = new BlogView();
/*This Is very important. Make sure To Link To the xsl file*/
wpBlogView.XslLink = “blog.xsl”;
wpBlogView.Title = “Recent Blog Posts”;
wpManager.AddWebPart(wpBlogView, “WebPartZone”, 0);
Hope this helps some one in need 🙂