Skip to content

Instantly share code, notes, and snippets.

@jacknycz
Last active August 29, 2015 13:59
Show Gist options
  • Save jacknycz/10732066 to your computer and use it in GitHub Desktop.
Save jacknycz/10732066 to your computer and use it in GitHub Desktop.
/**
* Enable Widget shortcodes.
*/
add_filter('widget_text', 'do_shortcode');
/**
* Custom Widget Shortcode.
*/
add_shortcode('custom', 'custom_widget');
function custom_widget($attr, $content) {
ob_start();
get_template_part('inc/custom');
$ret = ob_get_contents();
ob_end_clean();
return $ret;
}
Then in the widget just add [custom] and it should work.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment