• Hello, I’m buidling a custom php-menu for my template; and one of my category menu is highlighting if we are in a specific category (a “root” category).

    <?php
    	}elseif (is_category('13')) { ?>
    		ShowMenu (3);
    	<?php
    	}

    But the problem is, that if we are browsing a child-category; this doesn’t work anymore.

    So : how can I change my condition and build it to detect the parent category ? (not just 1 level up, because if I have sub-sub-categories, it will broke again)

    Thanks !

    I’ve read about
    <?php the_category(‘separator’, ‘parents’ ); ?>
    but it must be in the loop so I can’t use it.

Viewing 1 replies (of 1 total)
  • Thread Starter grosbouff

    (@grosbouff)

    I’ve found something, but it doesn’t work if you click on a post… ??
    Any idea ?

    if (function_exists('bloginfo')) { //teste si on est dans le blog
    
    	$menu_categories = get_category_parents($cat, FALSE, '||', TRUE);
    	$menu_categories = explode("||", $menu_categories);
    	$menu_parent_cat = $menu_categories[0];	
    
    	if ( ($menu_parent_cat == 'anima') || (is_home()) ) {?>
    		ShowMenu (1);
    	<?php
Viewing 1 replies (of 1 total)
  • The topic ‘Highligh a element of my custom menu while browsing subcategories’ is closed to new replies.