Forum Replies Created

Viewing 7 replies - 1 through 7 (of 7 total)
  • Thread Starter carlsen.rasmus

    (@carlsenrasmus)

    thanks,

    I did that, but it did’nt work, but when I look closer, I can se my typing-F***.

    Now it works just fine.

    ras

    Thread Starter carlsen.rasmus

    (@carlsenrasmus)

    ps: blog-excerpts.php is a template …

    Thread Starter carlsen.rasmus

    (@carlsenrasmus)

    Strange: this works as it should,

    add_filter( ‘nav_menu_css_class’, ‘add_custom_class’, 10, 5 );

    function add_custom_class( $classes = array(), $menu_item = false ) {
    if ( (is_single() || is_category())
    && 44 == $menu_item->ID
    && ! in_array( ‘current-menu-item’, $classes ) ) {
    $classes[] = ‘rasmus-test’;
    }
    return $classes;
    }
    but if I ad the is_archive … it highlights the menu-item all the time.

    ras

    Thread Starter carlsen.rasmus

    (@carlsenrasmus)

    sorry – it does’nt work. It highight the menu-item (with id 44) all the time …

    ras

    Thread Starter carlsen.rasmus

    (@carlsenrasmus)

    then I can just stay with:

    add_filter( 'nav_menu_css_class', 'add_custom_class', 10, 4 );
    
    function add_custom_class( $classes = array(), $menu_item = false ) {
        if ( (is_single() || is_category || is_archive())
    && 44 == $menu_item->ID
    && ! in_array( 'current-menu-item', $classes ) ) {
            $classes[] = 'rasmus-test';
        }
        return $classes;
    }

    it works just fine – however, in af child-theme it would be better for later theme-use, that it was based on something else than “44”.

    ras

    Thread Starter carlsen.rasmus

    (@carlsenrasmus)

    thanks! How blind can I be!

    this did it:

    if ( (is_single() || is_category())
    && 44 == $menu_item->ID
    && ! in_array( 'current-menu-item', $classes ) )

    However – I dont get how to incert the menu-item ID by the templatename …

    this:

    add_filter( 'nav_menu_css_class', 'add_custom_class', 10, 4 );
    
    function add_custom_class( $classes = array(), $menu_item = false ) {
        if ( (is_single() || is_category || is_archive())
    && ( is_page_template('blog-excerpt.php'))
    && ! in_array( 'current-menu-item', $classes ) ) {
            $classes[] = 'rasmus-test';
        }
        return $classes;
    }

    … wont work. It highligt all menu-items except the one base on blog-excerpt ??

    ras

    Thread Starter carlsen.rasmus

    (@carlsenrasmus)

    Solved (almost):

    this:

    .menu .current_page_item a,  {
    	background-color: #343434;
    }

    went to this

    .menu .current_page_item a, li.current-page-ancestor a,  {
    	background-color: #343434;
    }

    However; still need to find out how to do the same trick with post and categories.

    ras

Viewing 7 replies - 1 through 7 (of 7 total)