Skip to content

Instantly share code, notes, and snippets.

@briansteeleca
Last active August 29, 2015 14:06
Show Gist options
  • Save briansteeleca/cf09231e22eb94ed1c32 to your computer and use it in GitHub Desktop.
Save briansteeleca/cf09231e22eb94ed1c32 to your computer and use it in GitHub Desktop.
A WordPress shortcode for adding a div wrapper with attributes id and class. You can use this in the Visual Editor so that it can be seen and won't accidentally get stripped out by someone editing the entry. #wordpress #shortcode #wrap
<?php
//* Do NOT include the opening php tag
function bsca_divwrapbegin ( $atts ) {
$a = shortcode_atts(
array(
'id' => '',
'class' => '',
),
$atts );
return '<div id="' . esc_attr( $a['id'] ) . '" ' . 'class="' . esc_attr( $a['class'] ) . '">';
}
add_shortcode( 'wrap_begin', 'bsca_divwrapbegin' );
function bsca_divwrapend() {
return '</div>';
}
add_shortcode( 'wrap_end', 'bsca_divwrapend' );

[wrap_begin id="farm-to-table" class="anchor"]

FARM TO TABLE

Farm-to-table bicycle rights swag, readymade ethnic Etsy hella salvia. Meh squid XOXO biodiesel food truck, Blue Bottle fanny pack. XOXO retro lomo, tattooed leggings kitsch bespoke. Occupy drinking vinegar Cosby sweater farm-to-table slow-carb, semiotics ethical artisan Odd Future PBR flexitarian mixtape street art PBR&B bitters. Scenester direct trade Pinterest, YOLO biodiesel flannel meggings Intelligentsia Schlitz Tumblr distillery. Viral twee Bushwick fixie, plaid raw denim retro. Small batch fashion axe mixtape slow-carb, gentrify banh mi American Apparel dreamcatcher XOXO kale chips cred 90's put a bird on it.

[wrap_end]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment