Advertisement
deliciousthemes

Line - Using Widgets as Shortcodes

Dec 19th, 2012
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.75 KB | None | 0 0
  1. /*-----------------------------------------------------------------------------------*/
  2. /*  Widgets
  3. /*-----------------------------------------------------------------------------------*/
  4.  
  5. function my_widget_shortcode( $atts ) {
  6.  
  7. // Configure defaults and extract the attributes into variables
  8. extract( shortcode_atts(
  9.     array(
  10.         'name'  => '',
  11.         'instance' => '',
  12.     ),
  13.     $atts
  14. ));
  15.  
  16. $instance = str_ireplace("&", '&' ,$instance);
  17.  
  18. $args = array(
  19.     'before_widget' => '<div class="widget">',
  20.     'after_widget'  => '</div>',
  21.     'before_title'  => '<h3>',
  22.     'after_title'   => '</h3>',
  23. );
  24.  
  25. ob_start();
  26. the_widget( $name, $instance, $args );
  27. $output = ob_get_clean();
  28.  
  29. return $output;
  30.  
  31. }
  32.  
  33. add_shortcode( 'widget', 'my_widget_shortcode' );
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement