There isn’t an RSS of the names of the categories specifically otherwise I would have used the XML from the RSS feed with XSLT to display the category list that way.
There is a handy function named add_feed()
. You can create any feed or other output with it. Should be useful in your case. And it is pretty simple too.
Sample plugin
<?php
/**
* Plugin Name: Category Feed
* Description: XML output for the categories located on /catxml/
*/
add_action( 'init', array ( 'T5_Cat_Feed', 'init' ) );
class T5_Cat_Feed
{
public static function init()
{
add_feed( 'catxml', array ( __CLASS__, 'display' ) );
}
public static function display()
{
$args = array(
'hide_empty' => 0,
'hierarchical' => 0,
'taxonomy' => 'category'
);
$cats = get_categories( $args );
if ( empty ( $cats ) or ! is_array( $cats ) )
{
return;
}
header( 'Content-Type: text/xml' );
print '<categories>';
foreach ( $cats as $cat )
{
$url = get_category_link( $cat->term_id );
print "<category>
<name>$cat->cat_name</name>
<id>$cat->term_id</id>
<url>$url</url>
<description>$cat->category_description</description>
<parent>$cat->parent</parent>
<count>$cat->count</count>
</category>"
;
}
print '</categories>';
}
}
Install as a plugin on your blog, visit the permalink settings page once to refresh the rewrite cache, and go to example.com/catxml/
or example.com/?feed=catxml
. You get a simple XML file with category data here.