将html单词添加到wp_list_categories中


Add html word into wp_list_categories

这是我的第一个问题,我非常希望这个网站。我的朋友们谈论得很好。

我有一个代码,其中有3列的类别列表,但我想在每个类别之前添加单词"Asesor"。

示例:

Asesor类别1Asesor 2类

这是我的代码:

<?php
// Grab the categories - top level only (depth=1)
$get_cats = wp_list_categories( 'echo=0&title_li=&depth=1&hide_empty=0&exclude=1,762,899,951' );
// Split into array items
$cat_array = explode('</li>',$get_cats);
// Amount of categories (count of items in array)
$results_total = count($cat_array);
// How many categories to show per list (round up total divided by 3)
$cats_per_list = ceil($results_total / 3);
// Counter number for tagging onto each list
$list_number = 1;
// Set the category result counter to zero
$result_number = 0;
?>
<ul class="cat_col" id="cat-col-<?php echo $list_number; ?>">
<?php
foreach($cat_array as $category) {
    $result_number++;
    if($result_number % $cats_per_list == 0) {
        $list_number++;
        echo $category.'</li>
        </ul>
        <ul class="cat_col" id="cat-col-'.$list_number.'">';
    }
    else
        echo $category.'</li>';
}
?>
</ul>

我试着在一行中添加这个,但不起作用:

echo "Asesor" .$category.'</li>';

有人能帮我吗?真的很感谢!

我建议您使用http://codex.wordpress.org/Function_Reference/get_categories相反默认情况下,它将检索对象数组,这样您就可以循环通过并回显您想要的