Posts Tagged ‘post structure’

Tweaking WordPress – Sitemap

March 31st, 2010

 

Way To Improve Your Content Overview

 

 

 

I was looking for some site map solution that would satisfy my picky needs (to be seen as wp page not as wp post and to show list of categories with posts inside them). Sitemap is cool webmaster tool. It helps visitor to easy navigate through your site. It shows page structure and also, some sitemap WordPress plugins create sitemap.xml file that is very useful when search engines map your site. I found couple that were partially good enough. First was WP-Archives by Jim Penaloza Calixto (more info at http://blog.unijimpe.net/, wp plug-in download url – http://downloads.wordpress.org/plugin/wp-archives.zip). It was easy and simple to install and configure. It is installed as post and it shows posts in chronological order (but not what category they belong) with day/month info. The second was PS Auto Sitemap by Hitoshi Omagari (more info at http://www.web-strategy.jp/wp_plugin/ps_auto_sitemap/, wp plug-in download url – http://downloads.wordpress.org/plugin/ps-auto-sitemap.zip). It had visually all that I wanted (categories with list of posts that belong to them), but it was implemented as a post. I didn’t want that (yes, I know I could easily put it in sidebar as a link, but I wanted it to be on the top with other page links). So I was using the WP Archives plug-in for a while. It looked like this:


Old Sitemap

 

When I managed to find more free time, I decided to fix this. I used PS Auto Sitemap plug-in and did some simple code change in php.

After plug-in installation, I edited header.php of my current theme and I put something like this at the place where pages are being listed:

<li <?php if($post->ID == xxx) echo ‘class=”current_page_item”‘; ?>><a href=”http://yoursite/post-name-xxx”>Post Name</a></li>

Here, xxx is ID of your plug-in post that you can find in your post URL at the end, or in _posts table of your WordPress database. In my case ID was 391, table name was wp_posts, page url was www.geekwidget.com and post name was Sitemap Widget, and it looked like this:


Header Tweak

 

Now, it was still a post. In some themes, like in one that I am using, it had previous post and next post links whenever a post was separately opened. Since I was picky, as mentioned, I wanted to change that, too. I edited single.php in same folder and put something like this:

<?php if ($post->ID != xxx) { ?>

<div>
<div><?php previous_post_link(‘&laquo; %link’) ?></div>
<div><?php next_post_link(‘%link &raquo;’) ?></div>
</div>

<?php } ?>

The xxx part was again plugin post id. In my case it looked like this:


Single Tweak

 

After that I had what I wanted:


New Sitemap