Using WordPress Template for creating a Sitemap
Wednesday, July 16, 2008Is there a feature in WordPress, sometimes overlooked, which makes it very versatile, especially for those who create themes: the use of Template! A template is simply a file included in the theme folder. To identify it as a template just insert a special comment at the beginning of the file in PHP:
- / *
- Template Name: Sitemap
- * /
Leveraging this feature you can create a blank page, with the standard procedure of WordPress, and connect it to our template. If you create a file, for example sitemap.php (adding that comment indicated above) and loads it in the folder of your theme, you'll notice that WordPress editor when creating a page (not a post) menu Template (below) will contain the name of the template file loaded. As mentioned in section template:
Some themes have custom templates you can use for certain pages that may contain additional features or custom graphics. [...]
I, for example, I used this feature to create a dynamic page (which then executes PHP code) that shows a real sitemap of your blog.
Creating a Sitemap page
First create a file sitemap.php and load inside the folder of your theme. Wordpress created by a new page, give it a name and select the Template from the menu that is located below the editor! Finished!
The template, being part of the theme, also contains the entire structure of the theme itself and is therefore important to know that he writes correctly. Yet here is a skeleton of a Sitemap that you can tailor the theme you have installed:
- <? Php
- / *
- Template Name: Sitemap
- * /
- "content" > <div id = "content">
- "post" id = "post-<?php the_ID(); ?> "> <div class = "post" id = "post-<? php the_title ();?>">
- <h2> <? php the_title ();?> </ h2>
- "date-time" ><?php the_time ( 'lj F, Y' ) ?>< / small> <small class = "date-time"> <? php the_time ( 'lj F Y')?> </ small>
- 'showposts=1000' ) ; <? Php $ archive_query wp_query = new ( 'showposts = 1000');
- have_posts()) : $archive_query->the_post(); ?> while ($ archive_query-> have_posts ()): $ archive_query-> the_post ();?>
- <? Php endwhile;?>
- ) ; ? > <? Php wp_get_archives ( 'type = monthly');?>
- " alt="RDF/RSS 1.0 feed"> <acronym title = "Resource Description Framework" > RDF </acronym> / <acronym title = "Really Simple Syndication" > RSS </acronym> 1.0 feed < / a>< / li> <li> <a href = "<? php bloginfo ( 'rdf_url');?>" alt = "RDF / RSS 1.0 feed"> <acronym title = "Resource Description Framework"> RDF </ acronym> / <acronym title = "Really Simple Syndication"> RSS </ acronym> 1.0 feed </ a> </ li>
- " alt="RSS 0.92 feed"> <acronym title = "Really Simple Syndication" > RSS </acronym> 0.92 feed < / a>< / li> <li> <a href = "<? php bloginfo ( 'rss_url');?>" alt = "RSS 0.92 feed"> <acronym title = "Really Simple Syndication"> RSS </ acronym> 0.92 feed </ a> </ li>
- " alt="RSS 2.0 feed"> <acronym title = "Really Simple Syndication" > RSS </acronym> 2.0 feed < / a>< / li> <li> <a href = "<? php bloginfo ( 'rss2_url');?>" alt = "RSS 2.0 feed"> <acronym title = "Really Simple Syndication"> RSS </ acronym> 2.0 feed </ a> </ li>













Muito útil!
An der deutschen Übersetzung solltest du aber noch etwas arbeiten.
[...] Http://www.undolog.com/2008/07/16/usare-i-template-wordpress-per-creare-una-sitemap/ [...]
Useful post! Thank you!