[resolved] Convert wp_list_bookmarks from unordered list to table? (4 posts)

  1. dalemoore
    Posted 3 years ago #

    Any one know how to convert the output of wp_list_bookmarks from an unordered list to, instead, a table - with each LI become instead a TD? The only thing I've found similar is this post: http://wordpress.org/support/topic/create-multiple-columns-from-long-list-of-wp_list_bookmarks-and-wp_list_authors which doesn't seem to work for me, even after changing get_bookmarks to wp_list_bookmarks. It just outputs the bookmarks like usual and then adds an empty table after it. I know it's not tabular data technically, but, I need it to be a table anyway because the layout needs to work in IE6+ and what I need to do can't be done except in CSS3, unless it's a table. Thanks for any assistance.

  2. vtxyzzy
    Posted 3 years ago #

    This might help:

    $bookmarks = wp_list_bookmarks('title_li=0&categorize=0&echo=0');
    $table_rows = preg_replace('/<li>/','<tr><td>',$bookmarks);
    $table_rows = preg_replace('/<\/li>/','</td></tr>',$table_rows);
    echo "<table>$table_rows</table>";
  3. Charles E. Frees-Melvin
    Posted 3 years ago #

    You could also just use before and after parameters of wp_list_bookmarks() rather than the preg_replace.

  4. dalemoore
    Posted 2 years ago #

    Thanks, vtxyzzy! Your solution works perfectly.

Topic Closed

This topic has been closed to new replies.

About this Topic