Shortcode in Menu no longer works.

A URL would help.
The most likely cause is your font-awesome library has been updated along with your theme.

Try changing this :
return '<i class="'.$a['set'].' fa-'.$a['icon'].$icon_size.'"'.$icon_color.'></i>';

to this :
return '<i class="'.$a['set'].' fab-'.$a['icon'].$icon_size.'"'.$icon_color.'></i>';
or this :
return '<i class="'.$a['set'].' fas-'.$a['icon'].$icon_size.'"'.$icon_color.'></i>';

Thanks for the quick answer.

The icon is displayed correctly in the Footer Widget. Only in the wp_nav_menu it is not processed correctly. So it’s not the actual HTML code, but WordPress suddenly doesn’t process the shortcode correctly in the menu.

Apparently, the following command is no longer processed correctly:

// Filter to use Shortcode in Navigation Menus
add_filter('wp_nav_menu', 'do_shortcode', 11);

I found the problem, these lines of code:

// Generated Code to insert
	return '<i class="'.$a['set'].' fa-'.$a['icon'].$icon_size.'"'.$icon_color.'></i>';

generates the following in the Footer Widget (works fine):

<i class="fas fa-home"></i>

But in the navigation menu the following (not working):

<i class="fas fa-“home”"></i>

Obviously additional quotation marks are used here for whatever reason!

That is curious!?

  • This reply was modified 1 day, 20 hours ago by guennionline.
  • This reply was modified 1 day, 20 hours ago by guennionline.

Agree it’s curious.
There is certainly nothing wrong with your syntax :
return ‘<i class=”‘.$a[‘set’].’ fa-‘.$a[‘icon’].$icon_size.’”‘.$icon_color.’></i>’;

As a work around, can you just replace your menu item using the FA directly ?
<i class=”fab fa-facebook-f”></i>
<i class=”fa fa-facebook-f”></i>

The problem was another plugin that generated the extra quotes in the menu. Had to set it differently, now everything works again.

90% of the errors sit in front of the monitor.

Thanks for your help

Regards Sascha

  • This reply was modified 1 day, 20 hours ago by guennionline.

Source link