How to Create a Page For Your Tags in WordPress
December 23, 2008 – 3:00 pmAt the time of this post I have more than 45 Tags, displaying them in a widget on the side took a lot of space that I could make use of. So my solution was to place them in a separate page.
There are 2 ways to display the tags in a page. The first is type in the tag names and link them to their hyperlinks manualy, which Im sure no one wants to do. And the second is to display the tags dynamically, which means the page reads the tags from the database everytime the page is loaded using the WordPress API. Here I show a simple way to do the latter.
First a plugin that runs PHP code in pages should be installed. I prefer Exec-PHP because its easy to use (you just type the PHP code inclosed in ), and has very good documentation. After installing the plugin create a new page and while in HTML view paste the code below.
<?php
$defaults = array('format' => 'array',
'smallest' => 10, 'largest' => 22, 'unit' => 'pt', 'number' => 0,
'orderby' => 'name', 'order' => 'ASC', 'exclude' => '' , 'include' => '');
$posttags = wp_tag_cloud($defaults);
$size = count($posttags);
for($i=0 ; $i < $size ; $i++)
{
echo $posttags[$i];
if($i < ($size -1))
echo ', ';
}
?>
The code uses the WordPress function wp_tag_cloud to get a list of tags formated using values of the $default array. To get more details about the function go to its Codex page.





