Skip to content

Instantly share code, notes, and snippets.

@ScarletPonytail
Created April 6, 2018 10:00
Show Gist options
  • Save ScarletPonytail/2d7e4733637e9947a8b70983a75cf345 to your computer and use it in GitHub Desktop.
Save ScarletPonytail/2d7e4733637e9947a8b70983a75cf345 to your computer and use it in GitHub Desktop.
PHP - Bracket syntax inline if statement
<?php if ( has_term( 'quote', 'sc_insighttype' ) ) {
$insightquote = get_post_meta( get_the_ID(), 'mbsc-insight-quote', true );
?>
<div class="insight-box-quote">
<?php if ( substr( $insightquote, 0, 1 ) === '"' || utf8_decode( substr( $insightquote, 0, 1 ) ) === utf8_decode( '“' ) ) { ?>
<?php echo '<h3>' . esc_html( $insightquote ) . '</h3>'; ?>
<?php } else { ?>
<?php echo '<h3>' . '“' . esc_html( $insightquote ) . '”' . '</h3>'; ?>
<?php } ?>
</div>
<?php } ?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment