I’m looking for the same thing. I also used the cat code above, and for my categories that works…. don’t seem to be able to do the same with the blogroll.
Have you had any luck since posting?
Ta, H
looking for a solution too – how to split the links widget ??
hey – I found this –
http://ww.wp.xz.cn/extend/plugins/wp-multicollinks/
plgin seems to work finr – you can split more than just your blogroll too –
hasnt been updated since 2008 but still looks good –
let me know how it works : )
Hello everyone!
The WP-Multicollinks plugin works pretty well but it just flows the links horizontally, this is actually really easy to do with CSS. Don’t get me wrong it is a great plugin.
However, I have been looking for a similar solution but I want the links to be evenly distributed between 3 columns and it lists them like so:
(Column 1) (Column 2) (Column 3)
Link 1 Link 4 Link 7
Link 2 Link 5 Link 8
Link 3 Link 6 Link 9
So I have cooked up a solution I want to share. I’m not a PHP ‘Expert’ by any means but this is working well for me.
Keep in mind you will need to alter it somewhat for 2 or 4 columns.
<?php
$term = get_term(2,'link_category') ;
$columns = round($term->count / 3);
$col1ct = $columns+1;
$col2ct = ($columns * 2)+1;
$linkCount = 1;
echo "<div id=\"linkCols\"><div id=\"col1\" class=\"col\">";
$linksX = get_bookmarks( array());
foreach ($linksX as $bookmark){
if($linkCount == $col1ct){
echo "</div><div id=\"col2\" class=\"col\">";
}
elseif ($linkCount == $col2ct){
echo "</div><div id=\"col3\" class=\"col\">";
}
?>
<a id='relatedlinks' href="<?php echo $bookmark->link_url; ?>" target=_blank>
<?php echo $bookmark->link_name; ?>
</a> <br /><br />
<?php
if($linkCount == $term->count){
echo "</div></div>";
}
$linkCount++;
}
?>
I put this code directly into a page template—you could easily create a function or a shortcode I imagine.
If you have any questions I will do my best to check this post.
I hope this helps.
*ian
livelearncreate’s solution is nice, but I changed it a bit. I wanted the link categories to be shown too. Also, I didn’t want to split up the categories. That means not every column will have the same height (except when they have the same amount of links) but that was not a big of a deal for me. If you still want that you should combine mine and livelearncreate’s code.
<?php
$nrOfColumns = 5;
$terms = get_terms('link_category', 'orderby=name') ;
$rowsPerColumn = round(count($terms)/$nrOfColumns);
for($i = 0; $i<$nrOfColumns; $i++) {
echo '<div class="column" id="column-' . $i . '">';
for($j = ($i * $rowsPerColumn); $j<($rowsPerColumn * ($i+1)); $j++) {
if(!isset($terms[$j]))
continue;
$bookmarks = get_bookmarks('category=' . $terms[$j]->term_id);
?>
<h2><?php echo $terms[$j]->name; ?></h2>
<ul>
<?php
foreach($bookmarks as $bookmark) {
echo '<li><a href="' . $bookmark->link_url . '">' . $bookmark->link_name . '</a></li>';
}
?>
</ul>
<?php
}
echo '</div>';
}
?>
The corresponding CSS:
#footer div.footer-menu .column { float: left; width: 170px; margin-right: 10px; }
#footer div.footer-menu .column ul { padding-bottom: 5px; margin-bottom: 5px; border-bottom: 1px dotted #ccc; }
#footer div.footer-menu h2 { font-size: 10pt; color: #fff; margin: 0; font-weight: bold; }
You can change the number of columns by changing the $nrOfColumns variable to a different number. Also note the column width and margin width in the first line of the CSS.
Frank