Filter id/class into wp_list_bookmarks? (3 posts)

  1. aprestmo
    Posted 6 years ago #

    I've been looking around for a way to include a ID or Class to the link generated by the wp_list_bookmarks.

    I thought I could use the "notes" area to store the name of the ID (or Class).

    I was the trying to filter this into the wp_list_bookmarks via my functions.php, but my PHP skills are too few, so I ended up with hacking the core file bookmark-template.php by adding this snippet around line 90.

    $id = $bookmark->link_notes;
    if ( '' != $id )
    $id = ' id="' . $id . '"';

    and putting the $id in the output a few lines down.

    Sure it works, but can anyone point out if it is possible to do this via the functions.php instead of this non-bulletproof method?


  2. cornhustlah
    Posted 6 years ago #


  3. cornhustlah
    Posted 6 years ago #

    ok so i found a solution to get ID's/classes added to my links, but i had to use get_bookmarks instead of wp_list_bookmarks ... the method i used is based on this dude's custom array found here

    here's what i came up with:

    $bookmarks = get_bookmarks( array('category_name'=>'About'));
    foreach ( $bookmarks as $bookmark ) {?>
    <li id="link-<?php echo $bookmark->link_id; ?>">
    <a title="<?php echo $bookmark->link_name; ?>" href="<?php echo clean_url($bookmark->link_url); ?>" target="_blank"><?php echo $bookmark->link_name; ?></a>
    <?php } ?>

Topic Closed

This topic has been closed to new replies.

About this Topic