Create An HTML Sitemap That’s Not A Plugin – 2nd Edition( 'Takes about 6 minutes to read. )

~~ Idol & The Goblet of Fire ~~
- 'Simply one more edifying post. Thumbs-up smiley - Enjoy.

This is another technical post in which I’m ‘getting my geek on’ as a musician/entertainer come tech-geek. I brand myself as just that: It’s what makes me unique and differentiates me from most other musicians.

Inventory Page
^ ^Image #1: The display of the HTML sitemap ^ ^

Every now and again I develop something really nerdy and I just have to post about it on my site no matter what. – This is one of those occasions.

– But it’s not just me and me alone who needs technical knowledge. All musicians & entertainers in this 21st Century age need to know how to market themselves. Whilst it’s true that some musicians don’t need to market themselves as their PR is all handled by their management as a part of their record deal or recording contract, the percentage of such musicians is in the minority compared to the multitude of indie artists who are all doing their own marketing. – It’s those indie artists who could use some technical help from time to time with regard to their online presence; and this website sets out to kill two or more birds with a single stone by showing out my image as a techy geek musician, while at the same time in part helping out other musicians with technical issues where possible to some extent.

Why Avoid Plugins?

At this point you may be asking

‘How does creating an HTML sitemap that’s not a plugin help anyone in any way? That is just so ultra-geeky, and yeah it shows you up as a tech-nerd for sure; but what good is it to me? If I need an HTML sitemap on my ( WordPress self-hosted) website I can just go find an HTML sitemap plugin and install it.’

And you’d be 100% right in saying so: For the sake of speed that’s all you’d need to do.

What you haven’t considered, though, is that every plugin puts extra load on your database and slows down your website’s load time just that bit extra. The more things you can do without the help of a plugin the better at the end of the day.

If you take a look through the vast WordPress Plugin Repository you see a myriad of plugins for pretty much everything imaginable. You might even find a few that have been updated in the last year too. If you used every plugin that was compatible with your version of WordPress your site would never load fully. Try cutting that down to 100 plugins and your site would still take ages to load.

At time of writing this site has <40 active plugins running and it still takes too long to load. This is due to content links and JavaScript routines also, plus a lot of the images on this site still require optimising… But the last thing I want to do right now is to add more plugins.

As a musician/entertainer you want your site to be snappy and not take forever to load too; and so you want to avoid plugins as much as possible also. If you can get away with creating the desired function without using a plugin then do so.


So when you go and install that HTML sitemap plugin it writes new tables to your database and consumes server memory + processor-time in executing the new PHP routines.

The method I’ve come up with hardly touches your database in comparison, and uses fewer resources because the code is basically simplicity itself.

How To Do It

The way to accomplish this fete is to utilise a template rather than a plugin, to generate the HTML sitemap’s output. Why a template? Because you can run PHP routines on a template – whereas that’s not possible on a page (Unless you use a plugin, which defeats the point of the exercise.).

First of all then we need a template. I’ve used this phrase often before and wouldn’t be surprised if it were to become clichéd: –

The best way to start creating a new template is, first, to copy an existing template.

This is actually fairly easy to do. You want to look for a template file in your theme that generates a single page. Depending upon the theme you’re using that may possibly be the file page.php, or content-page.php, or something similar. When you find it, make a copy of it and add it to your theme’s files as inventory.php, or content-inventory.php .

How exactly you pull this off will depend upon your theme and how it works. I just attempted to write two clear sets of instructions for two of the main types of theme. After an hour I realised that the task was going to take ‘forever’, so I decided to deal with the basics only.

If you’re working with single.php only, and there is no other file involved in page-creation referenced from that template; ensure your copy template begins with something very similar to: –

< ?php
Template Name: inventory

It may well be best to keep the header to the bare minimum, so you may like to create a stripped-down header and use something like the following to call it: –

include("header_1.php"); ?>

Depending upon your theme you may need to change the lines: –

// Include the page content template.
get_template_part( 'content', 'page' );


// Include the page content template.
get_template_part( 'content', 'inventory' );

and create a content-inventory.php file by copying the content-page.php file, renaming it to content-inventory.php, and carrying out the following inside that file.

The HTML sitemap template we’re creating will need to do some basic functions in PHP.

At this point in the article, to save time and a load of explanation covering many reams  and pages of text; I’m suggesting that you use the PHP code from this site as follows: –


Frame & Title


Site Article Inventory: –


Call & Display Number of Posts

< ?php
$num_pages = wp_count_posts('post');
$num_pages = $num_pages->publish;


Number of Posts So Far:

< ?php
    echo $num_pages;

List Blog Posts

Listing of the latest post titles. ( Maximum 100 )

    < ?php $my_query = new WP_Query('showposts=100'); while ($my_query->have_posts()) : $my_query->the_post(); ?>


  • * < ?php the_title(); ?> *


    - Posted on:

    < ?php $author = get_the_author(); ?>Author: < ?php echo $author; ?>
              < ?php endwhile; ?>



    Call & Display Number of Pages

        < ?php
        $num_pages = wp_count_posts('page');
        $num_pages = $num_pages->publish;

    Number of Pages So Far:

        < ?php
        echo $num_pages;


    List Page Titles & Dates

    Listing of the page titles ( All )
    with publication dates

          < ?php wp_list_pages( 'sort_column=post_date&show_date=created' ); ?>


    How It Works: –

    Briefly the above works as follows: –

    • It calls and displays the number of published posts so far.
    • It then uses a loop to list and display a number of the most recent posts. The number of posts displayed can be set by changing the value of ‘showposts=  ‘ to the desired number. It is set to 100 by default in the example above. The post date and the post author are also displayed along with (below) the title of each post in chronological order.
    • The routine then calls and displays the number of published pages so far.
    • Following this it goes on to list the pages one by one chronologically, including the date of publication on the same line. (This uses the wp_list_pages function rather than a loop.)

    There are a few css references in the above code. Here is the corresponding css code in the colours used to display the page on this site. (Adjust at will to suit your own site.)


    .call {
    background: #fafeb9;
    border: #f8d36c solid 1px;
    margin: 1em;
    padding: 1em 1em 0.5em;

    .contentbox {
    background-color: #FDB;
    border-top: 1px solid #FFE3AD;
    border-bottom: 1px solid #FFE3AD;
    padding: 15px 10px;
    margin: 10px 0px;
    font-size: 15px;
    line-height: 23px;
    font-weight: bold;
    text-align: center;

    .grey {
    background: #E2E2E2;
    border: #f8d36c solid 1px;
    margin: 1em;
    padding: 1em 1em 0.5em;

    .whit {
    background: #ffffff;
    border: #f8d36c solid 1px;
    margin: 1em;
    padding: 1em 1em 0.5em;


    Because this template is just that – a template; lacking anything in the way of special SEO-ability – you won’t find the content that it presents as a page to be top-ranking on Google by any means.

    Having said that I very much doubt that you’ll lose many if any brownie-points from Google for displaying it. What you have accomplished, however, is you’ve created a template that does the work of a plugin and that uses less resources as a result. – Now that’s progress! – Google should at least reward you with a single Brownie-point for effort.

    As for copyright; well I don’t claim any copyright on the above PHP, or any other part of it; although you might like to remember that I wrote it and demonstrate that fact by giving me a mention if you decide to use it or your own version of it for your own purposes.

    …And, in a nutshell, that is basically that: I’ve tried to keep it as non-technical as possible; although I may have failed in that way. If it helps you or gives you ideas then so much the better: that is the aim of this website after all.

    To see this non-plugin working on this very site; go here and see for yourself.

    Published by


    I'm a singer - songwriter - producer, as well as an electronics & computer geek. 1 lifetime is not enough! S to the H to the A to the Zee; to the Zee to the A, L.I.V.E. - Shazzalive is alive! YOLO.

    100 PerCent Original

    If you like my music and/or my website/articles I'd like you to come back some time. - In fact I'd like to stay in touch with you, and have you come back here to this site sometime.

    The only way I can think of to achieve this is to ask you to leave me an email address on which I can contact you... So I'll tell you what I'll do: I'll give you almost 30 minutes of my self-composed mix in exchange for your email address. - 'Good deal yeah? - 'Great, we're singing from the same lyric-sheet here, as it were.

    When you enter your email address below and click "Get It Now", you'll be taken to my "Thank You" page, where you can download your music, and click on links to more of my stuff if you're interested too.

    Since I will then have your email address I'll send you email from time to time; like when I have something interesting to say, or when I release something, or even when I think there's something I've found that you'd be interested in.

    You can unsubscribe from these emails at any time if you get fed up with getting them, and I won't complain about it. - And you won't hear from me again; unless you re-subscribe.

    'Sound good to you? OK let's do this: 'See the stuff below? Follow the instructions - it's really easy - and we're away.
    'See you there...

    *Opt-in for Sharron-Idol's emailing list - stay connected with this great new site...

    Join Emailing List Here

    There's an instrumental mix waiting for your ears.

    Go on - hit the button: - You know you want to hear the free mix. :)

    SPAM is EVIL - I am an angelic artist and I will NEVER spam you. 'Promise.