i just posted part of this code in other threads, but here's the full version
what motivated me was that Relevanssi plugin doesn't search inside the links, and the solution is doing a page with a shortcode, [myblogroll] in this case
function printLinks( $atts, $content = null ) {
$ritorna = "";
$taxonomy = 'link_category';
if (!function_exists('mylinkorder_get_bookmarks')) {
$args = array('orderby'=>'name');
} else {
$args = array('orderby'=>'order');
}
$terms = get_terms( $taxonomy, $args );
if ($terms) {
foreach($terms as $term) {
if ($term->count > 0 && $term->slug!='uncategorized') {
$ritorna .= "<br /><h3>".$term->name."</h3>";
if (!function_exists('mylinkorder_get_bookmarks')) {
$bookmarks = get_bookmarks( array(
'orderby' => 'name',
'order' => 'ASC',
'category_name' => $term->name
));
} else {
$bookmarks = mylinkorder_get_bookmarks( array(
'orderby' => 'order',
'category_name' => $term->name
));
}
foreach ( $bookmarks as $bm ) {
$ritorna .= sprintf( '<a class="relatedlink" href="%s">%s</a><br />', $bm->link_url, __($bm->link_name) );
}
}
}
}
return $ritorna;
}
add_shortcode('myblogroll', 'printLinks');
note that:
- the code is redundant, in case of deactivation of my-link-order
- i'm exluding the category 'uncategorized' in this example