Skip to content

Instantly share code, notes, and snippets.

@juanbzpy
Last active October 15, 2017 15:04
Show Gist options
  • Save juanbzpy/6b213e4fcafe1426df01 to your computer and use it in GitHub Desktop.
Save juanbzpy/6b213e4fcafe1426df01 to your computer and use it in GitHub Desktop.
How to add social icons using Option Tree and Font Awesome in WordPress

in header.php

<?php
  if ( function_exists( 'ot_get_option' ) ) {
    $social_media_channels = array(
      "Facebook" => "fa fa-facebook-square",
      "Twitter" => "fa fa-twitter-square",
      "Google+" => "fa fa-google-plus-square",
      "Linkedin" => "fa fa-linkedin-square",
      "Pinterest" => "fa fa-pinterest-square",
      "Youtube" => "fa fa-youtube-square"
    );
    
    $social_media_icons = ot_get_option( 'social_media_icons' );
  };
?>

<ul class="social-media-icons">
  <?php 
    if ( $social_media_icons ) {
      foreach ( $social_media_icons as $key=>$icon ) {
        if ( $social_media_channels[$icon['name']] ) {
          echo "<li class='social-media-icon'><a target='_blank' href='" . $icon['href'] . "'><i class='" . $social_mediaChannels[$icon['name']] . "'></i></a></li>";
        }
      }
    }
  ?>
</ul>
@rafelsanso
Copy link

On the loop you need to replace $social_mediaChannels to $social_media_channels.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment