Reputation: 1
This is my first question, i hope a lot of this site. My friends talk very good about it.
I have a code with categorie list in 3 columns, but i want add word "Asesor " before each category.
Example:
Asesor Category 1 Asesor Category 2
This is my code:
<?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>
I try add this in one line, but don't work:
echo "Asesor" .$category.'</li>';
Anybody can help me please? Really thanks!
Upvotes: 0
Views: 763
Reputation: 5755
I suggest you to use http://codex.wordpress.org/Function_Reference/get_categories instead. It will retrieve array of objects by default so you can just loop through and echo what you want
Upvotes: 1