• Resolved lizzief

    (@lizzief)


    I’m using WP 2.3.1

    I’m trying to use wp_list_bookmarks the same way that I’ve previously used get_links, but I can’t seem to get the parameters right.

    On my links page I have

    <h3>Personal Links</h3>
    <ul>
     <?php get_links(2); ?><br />
    </ul>
    
    <h3>Resources</h3>
    <ul>
     <?php get_links(25); ?><br />
    </ul>

    I would like to use wp_list_bookmarks in the same way. I’m really having problems getting it down. Can anyone help me with this?

    I’d also like to change my sidebar links widget to reflect a links rotation (similar to what I have in my left sidebar).

    The code I’m current using for that is:

    <ul><?php get_links('2,25', '<li>', '</li>', '', FALSE, 'rand', False, False, 10, True); ?>
    </ul>

    I would like to know what in the links widget I would change to achieve that (at the moment I’ve put the code in the sidebar above the dynamic sidebar.

    Any help would be greatly appreciated. I do know that I don’t immediately have to worry about changing the tags in my site’s theme, however it’s coming and I might as well get to it now.

    Thanks in advance.

Viewing 3 replies - 1 through 3 (of 3 total)
  • Moderator Samuel Wood (Otto)

    (@otto42)

    www.remarpro.com Admin

    Instead of this:

    <h3>Personal Links</h3>
    <ul>
     <?php get_links(2); ?>
    </ul>

    Try this:

    <?php wp_list_bookmarks(array(
    'title_before' => '<h3>',
    'title_after' => '</h3>',
    'categorize' => 0,
    'title_li' => 'Personal Links',
    'category_before' => '',
    'category_after' => '',
    'category' => '2',
    )); ?>

    As for the other one where you want the random 10 links:

    <ul>
    <?php wp_list_bookmarks(array(
    'orderby'=>'rand',
    'categorize' => 0,
    'title_li' => '',
    'limit' => 10,
    'category' => '2,25',
    )); ?>
    </ul>

    I think that should work. Changing the links widget itself is rather problematic though, I’d put the code into an ExecPHP widget:
    https://ottodestruct.com/blog/2006/04/09/fun-with-widgets/

    Thread Starter lizzief

    (@lizzief)

    Ah, I see what I was doing wrong! I didn’t put the (array ( in. Thanks so much, Otto! You seriously rock.

    I’ll go bang my head about the ExecPHP now. Thanks.

    Moderator Samuel Wood (Otto)

    (@otto42)

    www.remarpro.com Admin

    Well, the array is one way to do it. I like the array method because it makes it more obvious what parameters you’re passing.

    But these methods also take the query-string style parameters, so that last one could also be like so:
    <?php wp_list_bookmarks('orderby=rand&categorize=0&title_li=&limit=10&category=2,25'); ?>

    Both are the same thing, really. The query string gets changed to the array internally anyway, I just think the array looks better.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Having some trouble with wp_list_bookmarks’ is closed to new replies.