Simple Site Map Plugin
![]()
I created a site map plugin for Wordpress that simply lists all the pages you have on your site. It also comes with an optional category listing. You can edit the plugin to your liking. It was easy to create since it only has two main functions. The first function sitemap lists the pages using the wordpress generated tag wp_list_pages. I’ve also commented out a categories listing. You can add other listings if you’d like. The second major function generate_sitemap creates a shortcut you can use on any page you create when you go to Write –>Page. All you need to do is insert <– sitemap –> anywhere on that page and hit Publish.
Copy and paste the code below into a text editor such as notepad, and save it as sitemap.php. Then upload it to your site’s plugins folder. Activate the plugin in the Dashboard and create your site map page. To see a working site map, click here. If you have any questions, feel free to ask.
<br />
<?php<br />
/*<br />
Plugin Name: Site Map<br />
Plugin Author: Sue<br />
Plugin Description: Generates a site map based on pages but is customizable via plugin editor. You can get to that by clicking on the title of this plugin. Use &lt;!&ndash;&ndash; sitemap &ndash;&ndash;&gt; on any page in code view to display the site map.<br />
Plugin Author URI: http://endless-sonata.net<br />
Plugin URI: /wp-admin/plugin-editor.php?file=sitemap.php<br />
*/<br />
function sitemap() {<br />
echo "<ul>";<br />
wp_list_pages('title_li=');<br />
echo "</ul>";<br />
/*<br />
// optional list categories<br />
echo "<ul>";<br />
wp_list_categories('title_li=');<br />
echo "</ul>";<br />
// you may add any other list options you'd like<br />
*/<br />
}<br />
function generate_sitemap($content) {<br />
if (strpos($content, "<!-- sitemap -->") !== FALSE) {<br />
$content = preg_replace('/<p>\s*<!--(.*)-->\s*<\/p>/i', "<!--$1-->", $content);<br />
$content = str_replace('<!-- sitemap -->', sitemap(), $content);<br />
}<br />
return $content;<br />
}</p>
<p>add_filter('the_content', 'generate_sitemap');<br />
?><br />

It’s great to see you helping out and coding for others
. I suck at coding myself haha
!
Ooh, interesting! I’ve always wanted to learn PHP, and did manage to understand a bit while converting my layouts to WP. Hopefully I’ll get more time to figure it out after I graduate!
That’s great! Now all my pages don’t have to be listed on my index!
Oh, looks really interesting. My blog is not complex enough to require a site map yet; but if it ever does one day, I’ll remember to try yours out.
Did I ever mention how much you rock? Because you do
wow.. you made that script? cool! I’m using one now.
The one made by Dominic Foster.
Take Care!
-xoxo-