on my wordpress blog i have categories and subcategories ... and in single posts i want to be highlighted just the parent category (the subcategories are in dropdown and i dont want to be highlighted)
(dont make bad comments about my codes ... i`m a begginer ... very begginer)
i use this css code for categorries
HTML Code:
/* Navigation categories menu */
#navigation {float: left; width: 100%; height:38px; position: relative; background: #3F4C6B; font:13px/14px "Myriad Pro", Helvetica, Arial, sans-serif;}
#navigation span.home { display: block; float: left; margin: 10px 15px 0 0; padding: 0 10px 0 10px; border-right: 1px dotted #848484; }
#navigation span.home a:hover { opacity: 0.6; }
#navigation img { width: 20px; height:20px; }
.nav { width: 800px; float: left; margin-top: 2px; z-index:99; padding: 0; list-style:none; line-height:1; Text-transform: uppercase; }
.nav a {font:13px/14px "Myriad Pro", Helvetica, Arial, sans-serif; position:relative; color:#eeeeee; display:block; z-index:100; text-decoration:none; padding: 2px 5px; line-height: 33px; font-weight: bold; }
.nav a:hover { background:#39d; display:block; }
.nav li { float:left; margin: 0 10px 0 0; width: auto; line-height:20px; }
/* Drop-down menus */
.nav li ul { height: 29px; margin-top:-3px; margin-left:-75px; background:#39d; list-style: none; position: absolute; left: -999em; padding:5px 0 0 60px; border-width:1px 1px 0; z-index:999; font: italic 12px Georgia, Times, serif; text-transform: none; width: 918px; -moz-border-radius: 2px; -webkit-border-radius: 2px; -khtml-border-radius: 2px; border-radius: 2px;}
.nav li ul li { float: left; margin: 0 25px 0 0; padding-bottom: 5px; }
.nav li ul li a {padding:3px 2px 1px 2px; font-weight: bold; line-height: 20px; background-image: none; }
.nav li ul li a { color: #eee; }
.nav li ul li a:hover, .nav li ul li.current_page_item a, .nav li ul li.current_page_ancestor a, .nav li ul li.fake a { font-weight: bold; color: #3F4C6B; background:#eee; -moz-border-radius: 3px; -webkit-border-radius: 3px; -khtml-border-radius: 3px; border-radius: 3px;}
#wrapper .nav li ul ul li a:hover { color: #E6F235!important;}
.nav li:hover,.nav li.hover { position:static; }
.nav li:hover ul ul, .nav li.sfhover ul ul,
.nav li:hover ul ul ul, .nav li.sfhover ul ul ul,
.nav li:hover ul ul ul ul, .nav li.sfhover ul ul ul ul { left:-999em; }
.nav li:hover ul, .nav li.sfhover ul { left:75px; }
.nav li li:hover ul, .nav li li.sfhover ul,
.nav li li li:hover ul, .nav li li li.sfhover ul,
.nav li li li li:hover ul, .nav li li li li.sfhover ul { left:auto; }
/* Tag Bar */
#search-bar {height: 20px; clear: both; padding: 0 0 11px 0; background: #3F4C6B; overflow:hidden; border-top:1px solid #FFCC00;}
.search-tags {padding:5px 10px 0 35px; color:#FFCC00; font-weight: bold; font-size:14px; }
.search-tags a {color:#39d; font-weight: bold; padding:0 10px 9px 0; }
.search-tags a:hover {border-top:2px solid #ff0032; color:#3F4C6B; background:#fff; padding:0 2px 1px 2px; -moz-border-radius: 4px; -webkit-border-radius: 4px; -khtml-border-radius: 4px; border-radius: 4px;}
/* featured button */
.featuredcat a {text-transform: uppercase; border-bottom:1px solid #ff0032; display: block; float: left; font:15px/16px "Myriad Pro", Helvetica, Arial, sans-serif; position:relative; color:#3F4C6B; display:block; text-decoration:none; padding: 3px 5px 2px 5px; margin:0 15px 0 0; line-height: 33px; font-weight: bold; background:#ADFFC8; border-bottom:;}
.featuredcat a:hover {background:#FFCC00; color:#3F4C6B;}
li.current-cat {background:#ffcc00; color:#2b2b2b; border-bottom:1px solid #ff0032; }
li .current_cat_parent {background:#ffcc00; color:#2b2b2b; border-bottom:1px solid #ff0032; }
li .current_cat_parent a {background:#ffcc00; color:#2b2b2b; border-bottom:1px solid #ff0032; }
this code
PHP Code:
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');
and this one to list cat.
PHP Code:
<ul id="main-nav" class="nav fl">
<?php wp_list_categories('hide_empty=0&sort_column=name&sort_order=asc&style=list&children=true&hierarchical=true&title_li=0&exclude=713'); ?>
</ul>
Any ideas? ....
i have in my signature the blog
