Skip to content

Instantly share code, notes, and snippets.

@pdewouters
Created March 21, 2012 17:46
Show Gist options
  • Select an option

  • Save pdewouters/2150133 to your computer and use it in GitHub Desktop.

Select an option

Save pdewouters/2150133 to your computer and use it in GitHub Desktop.
Registers a pricing_table shortcode
add_filter( 'the_content', 'shortcode_unautop' );
// Register a new shortcode: [pricing_table]
add_shortcode( 'pricing_table', 'cuj_pricing_table' );
add_shortcode('pricing_item', 'cuj_pricing_item');
// The callback function that will replace [pricing_table]
function cuj_pricing_table($attr,$content) {
$pricing_table = '<div class="pricing_table"><h4>' . $attr['title']. '</h4>' . do_shortcode($content) . '</div>';
return $pricing_table;
}
function cuj_pricing_item($attr){
$label = $attr['label'];
$price = $attr['price'];
$row = '<div class="pricing-row"><div class="pricing-label">' . $label . '</div>' . '<div class="pricing-price">' . $price . '</div></div>';
return $row;
}
// http://core.trac.wordpress.org/ticket/14050 - this bug adds br tags between shortcode outputs.
// use br {display: none;} to fix
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment