Posted By

crypticsoft on 04/11/12


wordpress links manager

Versions (?)

WordPress Links Manager - Display a random link from a category

 / Published in: PHP


Sometimes you just want a random link to display and outside of the default format, this works perfectly and removes all default html (list items / headings).

  1. //swap out the category (33) for your own category
  2. $links = wp_list_bookmarks('title_li=&categorize=0&sort_column=menu_order&show_name=1&echo=0&category=33&orderby=rand&limit=1');
  4. //create array from string returned by wp_list_bookmarks
  5. $bookmarks = explode('</li>', $links);
  7. //print without a link, if you want you could remove strip_tags() to bring the href back.
  8. print '<p>' . strip_tags( $bookmarks[0] ) . '</p>';

Report this snippet  

You need to login to post a comment.