Last active
December 7, 2016 22:08
-
-
Save robinbastien/079bc9410bedd1cf8035132e30aa2cd6 to your computer and use it in GitHub Desktop.
Output a flexible field group of buttons with options
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$link_type = get_sub_field('link_type'); | |
if( $link_type && $link_type != 'none' ) : | |
$link_target = ( $link_type == 'external' || $link_type == 'file' ) ? ' target="_blank"' : ''; | |
$link_text = get_sub_field('link_text'); | |
$link_url = get_sub_field('link'); | |
if( $link_type == 'internal' ) { | |
$link_text = empty( $link_text ) ? get_the_title( $link_url ) : $link_text; | |
$link_url = get_permalink( $link_url ); | |
} elseif( $link_type == 'file' ) { | |
$link_url = $link_url['url']; | |
} | |
?> | |
<a href="<?php echo $link_url; ?>" class="[sectionname]__link"<?php echo $link_target; ?>><?php echo $link_text; ?></a> | |
<?php | |
endif; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment