في أحد المواقع التي أستخدمها Wordpress 3.0 ، عندما أكون في منشور واحد ، فإن شريط التنقل الذي يعرض الفئات لا يمنح الفئة الأصل فئة "current_cat" ، وبالتالي لم يتم تمييز هذه الفئة.
كيف يمكنني أن أجعل وورد يعطي الفئة الرئيسية لتلك الفئة في وضع single_post؟
لقد وجدت الجواب هنا .
إضافة إلى function.php الوظيفة التالية وربط:
function sgr_show_current_cat_on_single($output) {
global $post;
if( is_single() ) {
$categories = wp_get_post_categories($post->ID);
foreach( $categories as $catid ) {
$cat = get_category($catid);
// Find cat-item-ID in the string
if(preg_match('#cat-item-' . $cat->cat_ID . '#', $output)) {
$output = str_replace('cat-item-'.$cat->cat_ID, 'cat-item-'.$cat->cat_ID . ' current-cat', $output);
}
}
}
return $output;
}
add_filter('wp_list_categories', 'sgr_show_current_cat_on_single');