Skip to content

Instantly share code, notes, and snippets.

@hereswhatidid
Created August 8, 2013 20:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save hereswhatidid/6188365 to your computer and use it in GitHub Desktop.
Save hereswhatidid/6188365 to your computer and use it in GitHub Desktop.
Enable shortcode attribute override filter to a sample shortcode
<?php
add_shortcode('sample', 'sample_shortcode');
function sample_shortcode($attr, $content = null) {
extract(shortcode_atts(array(
'title' => 'Hello, World!',
'testatt' => 'itworks'
), $attr, 'sample'));
return '<div style="border: 1px solid #333; border-radius: 10px; padding: 12px;"><h3>' . $title . '</h3>' . $content . '</div>';
}
function override_sample_shortcode_title( $out, $pairs, $atts ) {
$out['title'] = 'Modified!';
return $out;
}
add_filter( 'shortcode_atts_sample', 'override_sample_shortcode_title', 10, 3 );
?>
@hereswhatidid
Copy link
Author

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