Guest User

Untitled

a guest
Jan 22nd, 2018
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.72 KB | None | 0 0
  1. <?php
  2.  
  3. //register the shortcode
  4. add_shortcode( 'social_icons', 'simons_social_shortcode' );
  5.  
  6.  
  7. function simons_social_shortcode(){
  8. //put the field names for the social icons in an array. (must match the font awesome name, if
  9. //this isn't possible you could use key => value pairs)
  10. $social_fields = ['facebook', 'twitter', 'youtube', 'instagram' ];
  11. //create a string for the icons.
  12. $html = '';
  13.  
  14. //loop through each of the social fields
  15. foreach ( $social_fields as $social_field ) {
  16. $social_link = get_field( $social_field, 'option' );
  17. if( $social_link ) {
  18. $html .= '<a target="blank" href="' . $social_link . '"><i class="fa fa-' . $social_field . '" aria-hidden="true"></i></a>';
  19. }
  20. }
  21. return $html;
  22.  
  23. }
Add Comment
Please, Sign In to add comment