Using the link manager on wordpress

Forget about get_links_list() and get_links().  These are deprecated and will never be back to wordpress!

Now there’s a new way of using the “Link Manager” section on wordpress.  With one and only one php function, you can call your links and place them wherever you want inside the template.  This is the function:

<?php wp_list_bookmarks( $args ); ?>

Of course you’ll need some arguments to make it work.  Let’s see some of them

‘limit’ => -1

This will list all your links, without any limit

‘category_name’ => ‘mycategory’

This argument will bring only the links inside the category ‘mycategory’

‘title_li’ => __(‘Bookmarks’)

This will give a Title to your links section

‘class’ => ‘advisors_links’

Or forget about a title, and just set a class that you can later modify using .css styling, so you add your own title, subtitle or whatever you have in mind.

‘category_before’ => ‘<li id=%id class=%class>’

This is an important one.  If you don’t want your links to automatically be wrapped with a <li> tag, you have to set this argument and define it with an empty ” value

‘category_after’ => ‘</li>’

Same thing for this one, set it to ” if you don’t want the function to automatically wrap your links into a list <li>

So a typical $args variable, could be declared like this:

<?php $args = array(
 'limit' => -1,
 'category_name' => 'advisor',
 'echo' => 1,
 'title_li' => __('Bookmarks'),
 'title_before' => '<h2>',
 'title_after' => '</h2>',
 'class' => 'advisors_links',
 'category_before' => '<li id=%id class=%class>',
 'category_after' => '</li>' ); ?>

So for example, if you want to put your links on the footer, try a code like this one:

<footer id="colophon" role="contentinfo">

<?php $args = array(
 'limit' => -1,
 'category_name' => 'advisor',
 'echo' => 1,
 'title_li' => __('Bookmarks'),
 'title_before' => '<h2>',
 'title_after' => '</h2>',
 'class' => 'advisors_links',
 'category_before' => '<li id=%id class=%class>',
 'category_after' => '</li>' ); ?>

<?php wp_list_bookmarks( $args ); ?>

</footer><!-- #colophon -->

 

 

 

 

Leave a Reply