Change header color 🎲 🎲

Jake Paris

in Maine, in 2024

Shortcode to Use a WordPress widget in Page Content

add_shortcode('do-widget',function($atts,$content){
	shortcode_atts(array(
		'widget' => null
	),$atts);

	if( $atts['widget'] == null )
		return 'No widget provided.';

	$widget = $atts['widget'];
	unset($atts['widget']);

	$widget_instance_args = http_build_query($atts);

	ob_start();
	the_widget($widget,$widget_instance_args);
	$widget_output = ob_get_contents();
	ob_end_clean();

	return $widget_output;
} );