• Hello!

    I’m having some problems with my menus and polylang. I’ve got two menus displayed on the website. Let’s say they are named “primary_nav” “mobile_nav”. The problem is that for some reason they are now the same. Whatever menu I call I still get the primary navigation. As soon as I deactivate Polylang the correct menus are displayed. What am I doing wrong here?

    I register my navigations like this:

    $data[‘primary_nav’] = new \Timber\Menu(‘primary-nav’);
    $data[‘mobile_nav’] = new \Timber\Menu( ‘mobile-nav’ );

    and fetch them like this:

    {% for item in primary_nav.items %}

    The page I need help with: [log in to see the link]

Viewing 9 replies - 1 through 9 (of 9 total)
  • I’ve got the same issue since the last update 2.2.4, using Timber as well but not sure if it’s related.

    I’m going to check that and will tell you what I find if author doesn’t reply before.

    For now, I fixed this using menu_id as parameter for `TimberMenu instance, instead of slug.

    With slug, TimberMenu tries to retrieve the menu_id using wpml_object_id_filter($slug, 'nav_menu'), hopefully it gives some help to the plugin author.

    codetaal

    (@codetaal)

    Had the same problems today. I disabled the wpml_object_id_filter in Timber’s Menu class. Correct me if I’m wrong, but in older version of polylang this function was not available and Timber worked so I figured out Timber would probably still run without it. And so it did. Ofcourse this is just a temporary fix. I commented the following out:

    
    // if ( function_exists('wpml_object_id_filter') ) {
    //    $menu_id = wpml_object_id_filter($locations[$slug], 'nav_menu');
    // }
    
    Thread Starter joelalexandersson

    (@joelalexandersson)

    That worked! Thanks! Is this a problem with timber or polylang?

    codetaal

    (@codetaal)

    The function exists in polylang. Somehow that function returns the wrong result. So I guess the problem is polylang.

    Plugin Author Chouby

    (@chouby)

    Hi,

    WPML and Polylang don’t use the same way to translate menus. Prior to 2.2.4, I did not support the deprecated function wpml_object_id_filter. I added it to improve the compatibility with another plugin, not being aware that I would break this one. Unlike in WPML, ‘nav_menu’ is not considered as a translatable post type in Polylang. That’s probably why things break now. I’ll try to investigate what’s wrong.

    jumika

    (@jumika)

    My workaround was this:

    $menuLocations = get_nav_menu_locations();
    $context['top_menu'] = new TimberMenu($menuLocations['theme_pos_top']);

    I would stay away from modifying plugins which i don’t own.

    Plugin Author Chouby

    (@chouby)

    I proposed a fix here: https://github.com/polylang/polylang/issues/187#issuecomment-341425263

    I cannot test it since I don’t have any Timber theme. Could you test it before I introduce it in Polylang?

    Thread Starter joelalexandersson

    (@joelalexandersson)

    Works for me!

Viewing 9 replies - 1 through 9 (of 9 total)
  • The topic ‘Problem with more than one menu at the same time – Polylang and timber’ is closed to new replies.