Blogroll links sorted by category in a table

I would like to create a blogroll page with a table where the links would be in the left table division and the description in the right division. So far, everything works...

Where it becomes tricky is that I would like a table for each link category. Unfortunately, the sql table links doesn't have a column link_category, it is located in taxonomy terms table.

I have tried many ways but I just can't get the right query. You can see my code below. It outputs the links and descriptions in a table, you can see it in action here: http://www.thebrutes.org/links/

$links = $wpdb-get_results("SELECT * FROM $wpdb-links ORDER BY link_name ASC");

echo "table";

foreach ($links as $link) {
$linkurl=$link-link_url;
$linkdesc=$link-link_description;
$linkname=$link-link_name;

echo "trtda href='$linkurl' target='_blank'$linkname/a/td";
echo "td$linkdesc/td/tr"; }

echo "/table";

So, if anyone would know a way to create a separate table for each link category created in my bookmarks, it would be greatly appreciated.

Or maybe is there an easier way but I haven't figured out how to use wp_list_bookmarks to output the links and their descriptions in separate table divisions...

Topic link-category terms blogroll taxonomy Wordpress

Category Web


As suggested, here is the "arrayed" version:

    $args = array( 
    'categorize' => 1, 
    'category_before' => '', 
    'category_after' => '</table>',
    'title_before' => '<h3>',
    'title_after' => '</h3><table><tr><th>Link</th><th>Description</th><tr>', 
    'orderby' => 'name', 
    'order' => 'ASC', 
    'before' => '<tr><td>', 
    'after' => '</td></tr>', 
    'between' => '</td><td>', 
    'show_description' => 1, 
    'show_name' => 1
    );

    wp_list_bookmarks( $args );

The Highlight of my answer isn't so much categorize as it is about outputing a table AFTER the category title and separating the kinl description from the link name, as showned on my page: http://www.thebrutes.org/links.

One detail I left out is that the wp_list_bookmarks function outputs a xoxo blogroll class, which is useless and very badly named (what's next, lolol class?). For those, like me who want to get rid of it, add these lines to your style.css:

ul.xoxo.blogroll { display: none; }

Voilà, I hope it'll help someone. I haven't found a single answer to this question, neither here nor anywhere else.


I've found a way to output the blogroll links in a table with the categories as title, without using a custom query:

wp_list_bookmarks('categorize=1&category_before=&category_after=</table>&title_before=<h3>&title_after=</h3><table><tr><th>Link</th><th>Description</th><tr>&orderby=name&order=ASC&before=<tr><td>&after=</td></tr>&between=</td><td>&show_description=1&show_name=1');

I hope it'll be of some use to someone else ;-)

About

Geeks Mental is a community that publishes articles and tutorials about Web, Android, Data Science, new techniques and Linux security.