Forums

[resolved] Adding special characters between bookmark links using WP_LIST_BOOKMARKS (4 posts)

  1. David Calhoun
    Member
    Posted 2 years ago #

    I found this forum post about inserting special characters between menu items (http://wordpress.org/support/topic/244544?replies=13#post-1054483), I'd like to figure out how to do the same thing, but with WP_LIST_BOOKMARKS function.

    This is what I've tried so far. I have just edited the code from the previous post. It will list the bookmarks correctly, but for some reason doesn't insert the " | " between them:

    <?php
    $links = wp_list_bookmarks('title_li=&categorize=0&sort_column=menu_order');
    
    foreach($links as $i => $page)
    	$links[$i] = '<li><a href="' . link_url($page->ID) . '" title="' . attribute_escape(apply_filters('link_name', $page->link_name)) . '">' . apply_filters('link_name', $page->link_name) . '</a></li>';
    
    echo implode('<span class="divider"> | </span>', $links);
    ?>

    If anyone can help me out, it'd be greatly appreciated. Thanks.

  2. alchymyth
    The Sweeper
    Posted 2 years ago #

    you need to add the 'echo' arg to use the list in php:
    http://codex.wordpress.org/Template_Tags/wp_list_bookmarks:

    echo
    (boolean) Display bookmarks (TRUE) or return them for use by PHP (FALSE).
    1 (True) - Default
    0 (False)

  3. David Calhoun
    Member
    Posted 2 years ago #

    @alchymth

    Thank you for you reply.

    I added the 'echo=0' argument, but now nothing is displayed.

  4. David Calhoun
    Member
    Posted 2 years ago #

    I found the answer to my question if anyone needs to know how to do this. You can find the answer at the following page:

    http://wordpress.org/support/topic/244544?replies=16#post-1312208

    <?php $links = wp_list_bookmarks('title_li=&categorize=0&sort_column=menu_order&echo=0');
    $bookmarks = explode('</li>', $links); //create array from string returned by wp_list_bookmarks
    array_pop($bookmarks); //pop last element off array
    echo implode('<span class="divider"> | </span>', $bookmarks); ?>

Topic Closed

This topic has been closed to new replies.

About this Topic