Subscribe to the RWT RSS Feed

RWT Webmaster Tools Blog

Resources and Tools You Can Use

 

Using wp_list_bookmarks in WordPress 2.1

It seems several things have caused various levels of consternation as people have upgraded their blogs to WordPress 2.1.

My main issue involved the use of wp_get_links.

In WordPress 2.1, there are significant changes to the way the Link Manager works:

  1. Any link management is now done through the Blogroll tab.
  2. ALL link categories are now kept in the same table as your blog categories
  3. Essentially, in WordPress 2.1 a category can have both posts and links.
  4. If you upgraded from a previous version, your link category ID’s will changed. If you used wp_get_links to dynamically populated various link lists and they are now empty, chances are the category id wp_get_links was pointing to either no longer exits or, because of the changes, does not have any links associated with it.
  5. Even changing your old wp_get_links commands to the right categories may not fix your problem. For some reason, the default behavior of wp_get_links no longer places <li> tags around each link.
  6. The replacement for wp_get_links seems to be wp_list_bookmarks
  7. wp_list_bookmarks is indeed more powerful – there are a lot more parameters to choose from
  8. Find out how to use wp_list_bookmarks
  9. Note: there are inaccuracies in the codex for wp_list_bookmarks. For example, you MUST enclose the whole string within the parenthese with single ticks: wp_list_bookmarks(‘all my parameters here’)
  10. Not every parameter seems to work. I am still trying to verify some issues. For example, wp_list_bookmarks includes the name of the category by default. This can be changed or turned off with the parameter title_li. However, I have been unable to get it to work. I will update this post if I find out the reason.

As way of example, here is how I am using wp_list_bookmarks to call a menu on my site:

<ul>
<?php wp_list_bookmarks('title_before=&title_after=&
categorize=1&category=52'); ?>
</ul>

This code produces this:

The nulls for title_before and title_after remove the default <h2> tag that occurs before and after the category title.

categorize=1 ensures the category name is display. If set to zero, the generic “Bookmarks” appears.

category=52 grabs the links associated with that category.

Like I mentioned above, I am still trying to figure out how the title_li parameter works.

If you have any questions please leave them below.

comments / trackbacks

9 Responses to “Using wp_list_bookmarks in WordPress 2.1”
  1. ups, sorry for my comments at other post :) , just delete it and try this one :

    <?php wp_get_links(‘category=52&before=<li>&after=</li>’); ?>

  2. [...] Jika tidak ingin menggunakan fungsi wp_get_links(), maka dapat dilakukan dengan cara menggunakan wp_list_bookmarks(‘args’) seperti panduan dari recommended web tools. [...]

  3. [...] ajuste que tuve que hacer fue para los links que ahora se llaman blogroll. Bueno ahí tuve que cambiar en el template de ‘wpgetlinks’ a ‘wplistbookmarks’ y argumentarlo. Ahora hay más [...]

  4. How can I remove the title of the link category?

  5. Cato, the title of the link category is removed with the title_li parameter. I have not been able to get it to work. I’ve tried every which way and I don’t think the wordpress code is totally correct. From the WordPress Codex:

    title_li
    (string) Text for the heading of the Page list. Defaults to ‘__(‘Bookmarks’)', which displays “Bookmarks” (the __(”) is used for localization purposes). If passed a null or empty value (”), no heading is displayed, and the list will not be wrapped with <ul>, </ul> tags.

  6. Hi Paul, check out this link…
    http://wordpress.org/support/topic/102345

  7. Hey,

    I read this great post before solving the problem, so I’ll paste this link I found:

    * http://trac.wordpress.org/ticket/3664

    If you apply the bug fix yourself to bookmark_template.php, title_li starts working again! :-)

    Best,
    Bob

  8. [...] WordPress 2.0以後,多了個新的書籤整理函式。原來是用get_link()來讀取連結清單,現在多了wp_list_bookmarks()可以用。功能更強,也更容易格式化。因為有了標準的格式化規格,因此就可以動點手腳,讓他可以輕鬆轉換成下拉式表單。 [...]

  9. [...] Jika tidak ingin menggunakan fungsi wp_get_links(), maka dapat menggunakan fungsi wp_list_bookmarks(‘args’) seperti panduan dari recommended web tools. [...]

Leave a Reply