Featured image in menu wordpres
the following is working good, but it breaks down if you activate wpml, do you have any idea how to surpass that?
function ad_filter_menu($sorted_menu_objects, $args)
{
if ($args-menu != 32)
return $sorted_menu_objects;
foreach ($sorted_menu_objects as $menu_object) {
// searching for menu items linking to posts or pages
// can add as many post types to the array
if (in_array($menu_object-object, array('post', 'page', 'um_page'))) {
// set the title to the post_thumbnail if available
// thumbnail size is the second parameter of get_the_post_thumbnail()
$menu_object-title = has_post_thumbnail($menu_object-object_id) ? get_the_post_thumbnail($menu_object-object_id, 'full') : $menu_object-title;
}
}
return $sorted_menu_objects;
}
Thx in advance