WordPress.org

Support

Support » How-To and Troubleshooting » [Resolved] Convert wp_list_bookmarks from unordered list to table?

[Resolved] Convert wp_list_bookmarks from unordered list to table?

  • dalemoore
    Participant

    @dalemoore

    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.

Viewing 3 replies - 1 through 3 (of 3 total)
  • vtxyzzy
    Member

    @vtxyzzy

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

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

    dalemoore
    Participant

    @dalemoore

    Thanks, vtxyzzy! Your solution works perfectly.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘[Resolved] Convert wp_list_bookmarks from unordered list to table?’ is closed to new replies.