0

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 "<tr><td><a 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...

1

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.

0

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 ;-)

  • Thanks for sharing your findings. It looks like the categorize is the important parameter for you? Maybe you could hightlight that in your answer? I find that using the input argument's array, instead of a very long input string, more manageable. – birgire Dec 2 '17 at 9:53

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.