Forum Replies Created

Viewing 3 replies - 121 through 123 (of 123 total)
  • Thread Starter Sofian777

    (@sofian777)

    Dear Kleor,

    thank you for fast reply. Works perfect like this.

    One more question: I would like that the digits stay 2digits, i mean i would like to have 9 as 09, so it stays 00:09:03 for example, instead of 9:3. Can this be changed as well in the code easily?

    Thread Starter Sofian777

    (@sofian777)

    Thanks for this, i tried it out but i couldnt get it to work. I copied it into my functions.php like this, is there anything else i should have done? (creating the childtheme i have done right since the css also worked. the file is named correctly, so i cannot find where i made my newbie mistake:)

    <?php
    add_filter( 'wp_nav_menu_objects', 'add_menu_parent_class' );
    function add_menu_parent_class( $items ) {
    
        $parents = array();
        foreach ( $items as $item ) {
            if ( $item->menu_item_parent && $item->menu_item_parent > 0 ) {
                $parents[] = $item->menu_item_parent;
            }
        }
    
        foreach ( $items as $item ) {
            if ( in_array( $item->ID, $parents ) ) {
                $item->classes[] = 'menu-parent-item';
            }
        }
    
        return $items;
    }
    ?>
    Thread Starter Sofian777

    (@sofian777)

    Hello Paul,

    thanks for reply, the second one is indeed a solution that works. Yet i would like to avoid using the custom menu and keep it automated, so the search continues for a solution to make WP itself add a class to all menu items that have children, as some themes are doing it (graphene or the elegantthemes.com themes).

    Actually this should have been solved multiple times and i found some posts and descriptions in the net, but i couldnt find a clear outcome there and my programming knowledge keeps me in need of a step-by-step explanation (i can add a function but i cannot program it by myself).

    Any further ideas?

Viewing 3 replies - 121 through 123 (of 123 total)