2
votes

Trying to get font awesome to work properly in wordpress, i am currently using the bones theme with the visual composer plugin. if i make a wysiwyg html box and copy some info in there with the class for font awesome it shows the icon however when published to the site it shows nothing. link below is the backend with icon appearing in preview but not text. backend page content Frontend not displaying it either front end not displaying

I have enqueued it like this:

  // Font Awesome Icons
  function font_awesome() {
  // CDN Network For Font Awesome Icons
  wp_register_style('font_awesome','http://netdna.bootstrapcdn.com/fontawesome/4.0.3/css/font-awesome.css');
  wp_enqueue_style('font_awesome');

  add_action('wp_print_styles', 'font_awesome');
}

have i missed something or is this a bug? any ideas? thanks.

1
Try with this link instead : https://maxcdn.bootstrapcdn.com/font-awesome/4.4.0/css/font-awesome.min.css - The netdna one give me an Access Denied, don't know why - though the maxcdn one seems to work great. - vard
changed the link but no luck, browser shows its there but im not sure if its stripping it out, i know wordpress is prone to stripping out tags: prntscr.com/80nij6 - Nicholas Ritson

1 Answers

1
votes

I just saw that your add_action call is inside your font_awesome function. So your function will never be called, and the font awesome script will never be enqueued.

Moreover, you shouldn't use wp_print_styles as it is deprecated since WP 3.3 and can provoke an incompatibility that make the scripts enqueue in admin. Use wp_enqueue_scripts instead:

function font_awesome() {
  wp_register_style('font_awesome','http://netdna.bootstrapcdn.com/fontawesome/4.0.3/css/font-awesome.css');
  wp_enqueue_style('font_awesome');
}
add_action('wp_enqueue_scripts', 'font_awesome');