If you are using WordPress SEO by Yoast, an auto generated sitemap is available for search engine submission.

http://yourdomainname.com/sitemap_index.xml

This is not a code snippet but I included it here because you might need this for your SEO needs.