wordpress のリンク リストに追加の css クラスをいくつかレンダリングしたいと思います。具体的には、リンク カテゴリを css クラスとしてレンダリングしたいので、例を示します。
link : http://www.foobar.com/
gategories : friends, colleagues
name : Foo Bar
現在、次のようにレンダリングされます:
<a href="http://www.foobar.com/" target="_blank">Foo Bar</a>
しかし、私はそれを次のようにレンダリングしたい:
<a href="http://www.foobar.com/" target="_blank" class="friends colleagues">Foo Bar</a>
次の関数を使用してリンクリストを作成していることは知っていますが、必要なことを行うためにそれを変更する方法がわかりません:
function wp_list_bookmarks($args = '') {
$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' => '<h2>', 'title_after' => '</h2>',
'category_orderby' => 'name', 'category_order' => 'ASC',
'class' => 'linkcat', 'category_before' => '<li id="%id" class="%class">',
'category_after' => '</li>'
);
$r = wp_parse_args( $args, $defaults );
extract( $r, EXTR_SKIP );
$output = '';
if(1) {
//output one single list using title_li for the title
$bookmarks = get_bookmarks($r);
if ( !empty($bookmarks) ) {
if ( !empty( $title_li ) ){
$output .= str_replace(array('%id', '%class'), array("linkcat-$category", $class), $category_before);
$output .= "$title_before$title_li$title_after\n\t<ul class=\"xoxo blogroll $category\">\n";
$output .= _walk_bookmarks($bookmarks, $r);
$output .= "\n\t</ul>\n$category_after\n";
} else {
$output .= _walk_bookmarks($bookmarks, $r);
}
}
}
$output = apply_filters( 'wp_list_bookmarks', $output );
if ( !$echo )
return $output;
echo $output;
}
?>
ありがとう!