Advertisement
Digitalraindrops

Link Shortcodes

Mar 24th, 2012
97
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.73 KB | None | 0 0
  1. /* Start ShortCode call [links category] */
  2. function dr_links($atts){
  3.     if( !isset( $atts[0] ) ) return '';
  4.     $category = $atts[0];
  5.     $links = '';
  6.     $bookmarks = get_bookmarks( array(
  7.         'orderby'        => 'name',
  8.         'order'          => 'ASC',
  9.         'category_name'  => $category
  10.     ));
  11.     if( $bookmarks ) {
  12.         $links = $links .'<ul class="post-links">';  
  13.         // Loop through each bookmark and add to output
  14.         foreach ( $bookmarks as $bm ) {
  15.             $links = $links ."\n" .'<li>';
  16.             $links = $links .'<a class="postlink" href="'.$bm->link_url.'">';
  17.             $links = $links .__($bm->link_name) .'</a></li>';  
  18.         }
  19.         $links = $links .'<ul>';
  20.     }
  21.     return $links;
  22. }
  23. add_shortcode('links', 'dr_links');
  24. add_filter('dr_links', 'do_shortcode');
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement