Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- /*
- * WordPress Shortcode
- * Install : Drop in your functions.php, or create a simple plugin (and drop all your functions there)
- * Description : Displays the blogroll of a site
- * Dependencies : Can be used with My-Link-Order plugin, or without it
- * Usage : write the shortcode in any post/page [myblogroll]
- * : to display only one category use this [myblogroll catslug="blogroll"]
- */
- function printLinks( $atts, $content = null ) {
- extract( shortcode_atts( array(
- 'catslug' => ''
- ), $atts ) );
- $ritorna = "";
- $taxonomy = 'link_category';
- if (!function_exists('mylinkorder_get_bookmarks')) {
- $args = array('orderby'=>'name','slug'=>$catslug);
- } else {
- $args = array('orderby'=>'order','slug'=>$catslug);
- }
- $terms = get_terms( $taxonomy, $args );
- if ($terms) {
- foreach($terms as $term) {
- if ($term->count > 0 && $term->slug!='uncategorized') {
- $ritorna .= "<br /><h3>".$term->name."</h3>";
- if (!function_exists('mylinkorder_get_bookmarks')) {
- $bookmarks = get_bookmarks( array(
- 'orderby' => 'name',
- 'order' => 'ASC',
- 'category_name' => $term->name
- ));
- } else {
- $bookmarks = mylinkorder_get_bookmarks( array(
- 'orderby' => 'order',
- 'category_name' => $term->name
- ));
- }
- foreach ( $bookmarks as $bm ) {
- $ritorna .= sprintf( '<a class="relatedlink" href="%s">%s</a><br />', $bm->link_url, __($bm->link_name) );
- }
- }
- }
- }
- return $ritorna;
- }
- add_shortcode('myblogroll', 'printLinks');
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement