polylang & filter "nav menu link attributes" – can't get the postid
-
hi
i built a theme as a “one page”, so i replaced the link of every menu-item with the page-id an added an anchor with a filter:function add_specific_menu_location_atts( $atts, $item, $args ) { if( $args->theme_location == 'main-nav' ) { $postid = url_to_postid( $atts['href'] ); $atts['href'] = '#'.$postid.''; } return $atts; } add_filter( 'nav_menu_link_attributes', 'add_specific_menu_location_atts', 10, 3 );
this works perfectly (eg. href=”#120″) but i used the polylang-plugin 1.9.1 and translated the pages, and now all links (only) in the translated menu are href=”#0″
i searched google and tried things like
$postid = pll_get_post(url_to_postid( $atts['href'] ));
but i couldnt get the pageid’s of the translated pages.is it somehow possible to get the ids from the linked, translated pages of the menu?
thanks in advance
- The topic ‘polylang & filter "nav menu link attributes" – can't get the postid’ is closed to new replies.