views:

38

answers:

2

Hello, I am using wordpress 3.01, and would like to list a number of child categories within a parent in this format. Without links.

{ 'cat1' , 'cat2' }

Is this possible?

http://codex.wordpress.org/Template_Tags/wp_list_categories this call seems like the right one, but I can't figure out how to list them without turning off links

Thanks, Azeem

A: 

You could extend the Walker_Category class and assign it to the walker attribute in the $args for wp_list_categories($args);.

By doing this, you have the ability to override how the links are rendered. In your case, you could probably just copy the code from Walker_Category and remove the part that wraps the category name in an anchor (<a>).

Maybe there's an easier way; I don't know -- I'm a WP n00b.

Here is one example I scouted out for you:

http://www.wprecipes.com/how-to-modify-lists-like-categories-and-blogroll-in-wordpress

Cory Larson
A: 

You can do this by using get_categories(); function. This returns an array of all categories. There is a codex article on it here: http://codex.wordpress.org/Function_Reference/get_categories


$categories = get_categories();
$parent_id = 25 //the id of the parent category
{ //this is your opening bracket
foreach($categories as $category){
if($category->parent == $parent_id){
echo "'" . $category->name . "',"
} //end if
} // end foreach

} //this is your end bracket

That should work - let me know how you go. Someone else might have a better solution but I've used similar solutions to this and it has worked without any problems.

Jack