Skip to content

August 30, 2010

Create sitemap for wordpress

The php code in the source will show the posts on the sitemap page

Today I am going to tell you how to make a user- and search engine friendly sitemap for wordpress that updates itself automatically whenever you add a post. First I have to explain a little about sitemaps. There are two types of sitemaps (at least):

  1. Sitemap.xml, this one you can submit to google for fastening your site’s indexing. This is ONLY for search engines, not for users. For this one there is a plugin that automatically creates the sitemap and submits it to Google everytime you update or write a post. The plugin is called google xml sitemap and can be downloaded from here. You only need to activate it, then it keeps your sitemap.xml up to date all the time.
  2. The sitemap page, this is just a page on your site where you list every single page that you have, like this one that I have on my site: The sitemap. This is good for users that wants an overview of your site, but also for search engines, because this works like an internal link-directory, this page contains a link to every page you have on your site. So even if a blogpost is two years old, there will be a link to it just one click away from the front page.

Building your sitemap for WordPress

We are going to concentrate on number two, because number one takes care of itself if you just install the plugin.

  1. Download Exec-php plugin. This plugin lets you run php-code in your posts. Do not worry if you don’t know php, I will tell you what to write. Activate that plugin.
  2. Download the WP_category_posts plugin. I have a modifyed (better) copy here (zip-file). Activate that plugin also.
  3. Create a new page on your WordPress blog. You can make a post also, but for this i suggest a page. Name it sitemap.
  4. Now we are going to use the two new plugins for making this page automatically show links to every page on the site. We will group the links by their categories. Create a heading for each category on the new page.
  5. Copy and paste this code under each heading: <ul><?php wp_cat_posts(9); ?></ul> . The number has to be changed to the ID of that category (9 is just an example).
  6. Open a new tab and go to admin panel –> posts –> categories, and check your category ID:s. Click on a category and you will see the ID in the adress field (example: ID=17). Make a list of the ID for every category.
  7. Go back to the sitemap page and put the right ID numbers in every place you have pasted the code <?php wp_cat_posts(9); ?>. This code will list all the posts in each category and output it as a link to that post.
  8. The sitemap is ready! Put a link to the sitemap in the footer, in the main menu, or in a widget, the important thing is that you can access the sitemap from the first page (or all pages) on your site. No matter how old your blogposts are, you will still find a link to them one click away from the front page!
The php code in the source will show the posts on the sitemap page

The php code in the source will show the posts on the sitemap page (from my personal blog jonathanbjorkskog.com)

Additional things you could do with the sitemap

If you have a lot of posts, you could consider to make the sitemaps for the different categories on different pages for keeping the sitemap page shorter.

If you have pages (about, contact, and so on) on your site, put a link to all of them also on your sitemap page.

If you make a new category, go to your category page and add that to your sitemap manually, include the code that pulls the ID, and that category will also be updated with posts.

Important! Do not edit the sitemap page through the “Edit”-button that some themes show under the content when you are logged in, this will make the php code unusable. Edit the sitemap page through the “admin panel –> pages” instead.

Read more from SEO for your theme
  • http://topsy.com/professionalwpthemes.com/create-sitemap-for-wordpress?utm_source=pingback&utm_campaign=L2 Tweets that mention Create sitemap for wordpress | Professional Wordpress Themes — Topsy.com

    [...] This post was mentioned on Twitter by professional themes, Jonathan Björkskog. Jonathan Björkskog said: Make a sitemap for your wordpress blog: http://professionalwpthemes.com/create-sitemap-for-wordpress [...]

  • http://sebastianostman.com Sebastian Östman

    Nice post. I will try to get it work and then I can comment later!

  • http://jonathanbjorkskog.com/make-a-sitemap-for-your-wordpress-blog Make a sitemap for your wordpress blog | Jonathans

    [...] my wordpress theming blog I recently made an article about how you can make a sitemap for your wordpress blog. I am not talking about the xml-sitemap, for that one you can use a plugin.  This is about a page [...]

  • http://wpthemes.chumpette.com/your-own-wordpress-designs/create-sitemap-for-wordpress-professional-wordpress-themes/ Create sitemap for wordpress | Professional Wordpress Themes | All About WordPress Themes

    [...] See the article here: Create sitemap for wordpress | Professional WordPress Themes [...]

  • http://www.bilenberg.net/sitemap-for-wordpress Sitemap för Wordpress : Mathias Bilenberg – råpublicerad

    [...] blev ombedd av @JonathanBJ att testa den här ”tutorialen” för att kolla ifall den är tillräkligt tydlig, det är väl självklart att man ställer upp på [...]

  • http://www.bilenberg.net Mathias Bilenberg

    Nice post,
    easy to use and does a lot fore the site/blog!

    Thx!

  • http://professionalwpthemes.com/customizing-permalinks-for-wordpress Customizing permalinks or url for wordpress | Professional Wordpress Themes

    [...] cover the plugins you need for fixing the titles of your posts, after that we will go over the sitemaps for your wordpress blog, and so on. Stay tuned and keep up making fantastic websites! Read more from Basics, SEO for [...]

  • http://professionalwpthemes.com/review-of-traction-theme-for-wordpress Review of Traction theme for wordpress | Professional Wordpress Themes

    [...] Google XML sitemap. I always install this one. It fastens the site’s indexation in Google. In addition to this one, you should also make an own sitemap fro your wordpress blog. [...]

  • Fjchairul

    U cant seems see the category id

  • Fjchairul

    U cant seems see the category id

  • http://www.hire-web-developers.com hire web developers

    This is a very intriguing post, I was looking for this information. You have got a great deal to say about this subject, and so much knowledge about this.  I am glad to know this blog.
    website developers for hire | hire a website developer

  • http://www.buy-premium-themes.com/find-the-best-corporate-wordpress-templates/ corporate wordpress themes

    A innovative application makes it feasible for WordPress, Joomla, Drupal, DotNetNuke and Blogger individuals to basically build templates within a short time period.

  • http://twitter.com/IwanSantoso18 Iwan Santoso

     introduce my name is John , a newbie blogger in the world I am very interested
    in the appearance tration theme by The Theme Foundry , but I am still confused
    for the setting to the pros . Please Explain and help. thank you

  • http://wordpresssitemapgenerator.com/ sitemap xml generator

    Sitemap Generator Plugin for WordPress. And wanted to use it to get a auto blog sitemap.  I’m a beginner of WordPress, and this is the first time I upload plugin, so there are so many problems accompany me until my success.

  • http://www.mindinventory.com/hire-magento-developers.php hire magento developer

    The Google XML Sitemaps plug-in has long been seen as the
    standard plug-in for creating sitemaps in WordPress and for good reason. The
    site map setting in WordPress located at the settings XML-sitemap in your
    WordPress admin panel.
     

  • http://www.mindinventory.com/hire-magento-developers.php hire magento developer

    The Google XML Sitemaps plug-in has long been seen as the
    standard plug-in for creating sitemaps in WordPress and for good reason. The
    site map setting in WordPress located at the settings XML-sitemap in your
    WordPress admin panel.
     

blog comments powered by Disqus