created my own wp-function „wp_list_bookmarks_v2“
located in „wp/wp-includes/bookmark-template“
( better to be included from outside of wp-folders, because of wp-updates.. )
i dont want to show links that have category=4 OR category=5 !!!
if i ask for links with category=4,5 then i mean
i want all links that have category=4 AND category=5 !!!
now, the script works fine for me
its a prototype, not giving you all the options of wp_list_bookmarks
its giving a list of links, target _blank, thats all
function wp_list_bookmarks_v2($args = '') { ////////////////////////////// // ORIG:wp_list_bookmarks $defaults = array( 'orderby' => 'name', 'order' => 'ASC', 'limit' => -1, 'category' => '', 'exclude_category' => '', 'category_name' => '', 'hide_invisible' => 1, 'show_updated' => 0, 'echo' => 1, 'categorize' => 1, 'title_li' => __('Bookmarks'), 'title_before' => '', 'title_after' => '
', 'category_orderby' => 'name', 'category_order' => 'ASC', 'class' => 'linkcat', 'category_before' => '
debug TRUE
"; // bedingung muss in klammern stehen!!!, beim einzeiler restliche anweisung muss nicht in {} stehen /* echo "args: ".$args ."
"; echo "r: ".$r ."
"; echo "r['category']: ".$r[category] ."
"; $category_split = split(',', $r[category]); echo "category_split: " ."
" ; print_r( $category_split )."
"; foreach ( $category_split as $single_cat ) { echo "single_cat: ".$single_cat."
"; } */ $my_bookmarks = array(); // counter key is link_id value is increased if it has the category $my_bookmarks_output = array(); // output complete links as arrays $category_split = split(',', $r[category]); if ($debug==1) echo " count( category_split ) ". count( $category_split ) ."
"; $count_category_split = count( $category_split ); // anzahl der angefragten categorien if ($debug==1) echo "
"; ////////////////////////////// // ORIG:wp_list_bookmarks if ( $categorize ) { //Split the bookmarks into ul's for each category $cats = get_terms('link_category', array('name__like' => $category_name, 'include' => $category, 'exclude' => $exclude_category, 'orderby' => $category_orderby, 'order' => $category_order, 'hierarchical' => 0)); ////////////////////////////// // ORIG:wp_list_bookmarks foreach ( (array) $cats as $cat ) { $params = array_merge($r, array('category'=>$cat->term_id)); if ($debug==1) echo "cat->term_id: ".$cat->term_id . "
"; //if ($debug==1) echo "params: "; //if ($debug==1) print_r( $params )."
"; $bookmarks = get_bookmarks($params); if ( empty($bookmarks) ) continue; if ($debug==1) echo "bookmarks: "; // ORIG:wp_list_bookmarks ////////////////////////////// ///////////////////////////// // CUSTOM foreach ( (array) $bookmarks as $bookmark ) { if ($debug==1) echo "
bookmark link_id:
"; if ($debug==1) print_r($bookmark->link_id); if ($debug==1) echo "
"; if (array_key_exists( $bookmark->link_id , $my_bookmarks ) ){ if ($debug==1) echo "array_key_exists: TRUE" ."
"; $my_bookmarks[ $bookmark->link_id ] = $my_bookmarks[ $bookmark->link_id ] +1; }else{ if ($debug==1) echo "array_key_exists: FALSE" ."
"; $my_bookmarks[ $bookmark->link_id ] = 1; // counter } if ($debug==1) echo "count:" .$my_bookmarks[ $bookmark->link_id ] ."
"; if ($debug==1) echo "count_category_split: ".$count_category_split."
"; if ( $my_bookmarks[ $bookmark->link_id ] == $count_category_split ){ if ($debug==1) echo "OKKKKKKKKKKKKKKKKKKKKK
"; array_push($my_bookmarks_output, $bookmark); } // CUSTOM ////////////////////////////// } } if ($debug==1) echo "----------------------------------------------
"; //print_r( $my_bookmarks_output ); echo "
"; foreach ( $my_bookmarks_output as $bm ) { //echo "bm: ".$bm->link_id."
"; $bookmark = get_bookmark($bm->link_id); echo ''.$bookmark->link_name.'
'; } } }