Son ayırıcıyı (normalde bir <br/>
etiketi) kaldırmaya çalışıyorum, ancak wp_list_categorilerden gelen son linkten onu "//" olarak değiştirdim.
Temelde bunu istiyorum:
Kategori 1 // Kategori 2 // Kategori 3 //
böyle görünmek için:
Kategori 1 // Kategori 2 // Kategori 3
İşte kullandığım geçerli kod:
<?php
$cat_array = array();
$args = array(
'author' => get_the_author_meta('id'),
'showposts' => -1,
'caller_get_posts' => 1
);
$author_posts = get_posts($args);
if ( $author_posts ) {
foreach ($author_posts as $author_post ) {
foreach(get_the_category($author_post->ID) as $category) {
$cat_array[$category->term_id] = $category->term_id;
}
}
}
$cat_ids = implode(',', $cat_array);
echo strtr(wp_list_categories('include='.$cat_ids.'&title_li=&style=none&echo=0'),array('<br />'=>' // '));
?>
Son satırı şu şekilde değiştirin:
$output = strtr( wp_list_categories( 'include='.$cat_ids.'&title_li=&style=none&echo=0' ), array( '<br />' => ' // ' ) );
echo preg_replace( '@\s//\s\[email protected]', '', $output );
Orada devam eden bir sürü ip işleme var. Sonuçları liste halinde çıkarmakta daha iyi olabilirsiniz
wp_list_categories('include='.$cat_ids.'&title_li=');
ve css ile stil:
li.cat-item { list-style-type: none; display: inline; }
li.cat-item:before { content: " // "; }
li.cat-item:first-child:before { content: none; }
Dikkate alınması gereken başka bir alternatif ...
Başka bir seçenek, patlayabilir -> pop -> implode ...
$output = explode( '<br />', wp_list_categories( 'include='.$cat_ids.'&title_li=&style=none&echo=0' ) );
array_pop($output);
echo implode(' // ',$output);