Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- //register the shortcode
- add_shortcode( 'social_icons', 'simons_social_shortcode' );
- function simons_social_shortcode(){
- //put the field names for the social icons in an array. (must match the font awesome name, if
- //this isn't possible you could use key => value pairs)
- $social_fields = ['facebook', 'twitter', 'youtube', 'instagram' ];
- //create a string for the icons.
- $html = '';
- //loop through each of the social fields
- foreach ( $social_fields as $social_field ) {
- $social_link = get_field( $social_field, 'option' );
- if( $social_link ) {
- $html .= '<a target="blank" href="' . $social_link . '"><i class="fa fa-' . $social_field . '" aria-hidden="true"></i></a>';
- }
- }
- return $html;
- }
Add Comment
Please, Sign In to add comment