Skip to content

Instantly share code, notes, and snippets.

@fjaguero
Created March 11, 2013 12:41
Show Gist options
  • Save fjaguero/5133974 to your computer and use it in GitHub Desktop.
Save fjaguero/5133974 to your computer and use it in GitHub Desktop.
Wordpress: Example Shortcode
/* @Workether ------------------------------------------------------------
English price
--------------------------------------------------------------------------*/
function price_shortcode( $atts, $content = null ) {
extract( shortcode_atts( array(
'class' => 'price',
), $atts ) );
$prefixblock = "block-price-";
$class = $prefixblock.esc_attr($class);
if ($content == null) {
return '<div class="block-price"><span class="price price-text-request">Price on</span><span class="price price-request">Request</span></div>';}
else {
return '<div class="block-price ' . esc_attr($class) . '"><span class="price price-text">Prices start at</span><span class="price price-number">' . $content . 'Sek</span></div>';}
}
add_shortcode( 'price', 'price_shortcode' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment