Last active
August 4, 2016 21:25
-
-
Save gfargo/6e80e0ae159328258c4d3c23a1740755 to your computer and use it in GitHub Desktop.
Example WP Shortcodes
This file contains hidden or 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
// | |
// Callout Shortcode | |
// | |
function callout_shortcode ($atts, $content = null) { | |
extract(shortcode_atts(array( | |
'title' => 'Product / Callout', | |
'subtitle' => '', | |
'text' => 'lorem content', | |
'image' => 'http://path/to/logo', | |
'align' => 'left', | |
'parallax' => true, | |
), $atts)); | |
$returnContent = ''; | |
ob_start(); | |
?> | |
<div class="callout-container callout-<?php echo esc_attr( $align ); ?>" data-parallax="<?php echo esc_attr( $parallax ); ?>"> | |
<div class="callout-content"> | |
<h3 class="callout-header"> | |
<?php echo esc_html( $title ); ?> | |
<?php if ( ! empty( $subtitle ) : ?> | |
<small><php echo esc_html( $subtitle ); ?></small> | |
<?php endif; ?> | |
</h3> | |
<p class="callout-content"><?php echo esc_html( $text ); ?></p> | |
</div> | |
<div class="callout-image"> | |
<img src="<? echo esc_attr( $image ); ?>" alt="<?= $title ?>"> | |
</div> | |
</div> | |
<?php | |
$returnContent = ob_get_clean(); | |
return $returnContent; | |
} | |
add_shortcode("callout", "callout_shortcode"); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment