Once upon...

an evening boring, while I pondered bored yet pensive,
Over many a strange and intriguing page of neglected blogs.
Swiftly, my mind began thinking, thinking of creating
A place of solace, of mapping of my thoughts and creations.
So welcome dear guests, if my words entice you.

The Voice

My name is Sue, simply Sue, an average idealist, a young adult, still uncertain about my future. My art and writings are by no means professional, but my passion for creating, creating, and creating is the living force that makes this site possible.

The Layout

Tested on:
  » Firefox 2.0.0.14, Opera 9.10,
    Netscape 8.1, Safari 3.1.1,
    Internet Explorer 7.0
  » Screen res: 1280x800
  » Color Quality: 32 bit

Affiliates

« Dailies | Apply? »

[ CLOSE ]
Gallery Graphics Anime Forums
AddThis Feed Button Bookmark and Share

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.

<?php
/*
Plugin Name: Site Map
Plugin Author: Sue
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 &amp;lt;!&amp;ndash;&amp;ndash; sitemap &amp;ndash;&amp;ndash;&amp;gt; on any page in code view to display the site map.
Plugin Author URI: http://endless-sonata.net
Plugin URI: /wp-admin/plugin-editor.php?file=sitemap.php
*/
function sitemap() {
echo "<ul>";
wp_list_pages('title_li=');
echo "</ul>";
/*
// optional list categories
echo "<ul>";
wp_list_categories('title_li=');
echo "</ul>";
// you may add any other list options you'd like
*/
}
function generate_sitemap($content) {
if (strpos($content, "<!-- sitemap -->") !== FALSE) {
$content = preg_replace('/<p>\s*<!--(.*)-->\s*<\/p>/i', "<!--$1-->", $content);
$content = str_replace('<!-- sitemap -->', sitemap(), $content);
}
return $content;
}

add_filter('the_content', 'generate_sitemap');
?>

Similar Posts

Creating a RSS Feeds Page,

6 Comments

Thank you for taking the time to leave a message. Your comment is much appreciated. Also, please leave a comment relevant to the posted topic. If this is your first time commenting, your comment will be held for moderation before being displayed. If you would like a custom avatar to appear beside your message, please sign up for an account on Gravatar
  1. Yara Identicon Icon
    Yara on 04.14.2008 at 21:20 (Reply)

    It’s great to see you helping out and coding for others :). I suck at coding myself haha :P!

  2. Marsha Identicon Icon
    Marsha on 04.16.2008 at 02:53 (Reply)

    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!

  3. Anya Identicon Icon
    Anya on 04.17.2008 at 10:21 (Reply)

    That’s great! Now all my pages don’t have to be listed on my index! :)

  4. Vickie Identicon Icon
    Vickie on 04.18.2008 at 00:00 (Reply)

    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. :)

  5. Chien Yee Identicon Icon
    Chien Yee on 04.18.2008 at 16:04 (Reply)

    Did I ever mention how much you rock? Because you do :P

  6. Babyjen Identicon Icon
    Babyjen on 04.21.2008 at 03:26 (Reply)

    wow.. you made that script? cool! I’m using one now. ;) The one made by Dominic Foster.

    Take Care!
    -xoxo-

Leave a comment

Quicktags: