jetpack_do_top_posts_widget

Create a shortcode to display the widget anywhere.

Description

jetpack_do_top_posts_widget( $instance ); 

Parameters (1)

0. $instance
The instance.

Usage

  1. if ( !function_exists( 'jetpack_do_top_posts_widget' ) ) { 
  2. require_once '/modules/widgets/top-posts.php'; 
  3.  
  4. // The instance. 
  5. $instance = null; 
  6.  
  7. // NOTICE! Understand what this does before running. 
  8. $result = jetpack_do_top_posts_widget($instance); 
  9.  

Defined (1)

The function is defined in the following location(s).

/modules/widgets/top-posts.php  
  1. function jetpack_do_top_posts_widget( $instance ) { 
  2. // Post Types can't be entered as an array in the shortcode parameters. 
  3. if ( isset( $instance['types'] ) && is_array( $instance['types'] ) ) { 
  4. $instance['types'] = implode( ', ', $instance['types'] ); 
  5.  
  6. $instance = shortcode_atts( 
  7. Jetpack_Top_Posts_Widget::defaults(),  
  8. $instance,  
  9. 'jetpack_top_posts_widget' 
  10. ); 
  11.  
  12. // Add a class to allow styling 
  13. $args = array( 
  14. 'before_widget' => sprintf( '<div class="%s">', 'jetpack_top_posts_widget' ),  
  15. ); 
  16.  
  17. ob_start(); 
  18. the_widget( 'Jetpack_Top_Posts_Widget', $instance, $args ); 
  19. $output = ob_get_clean(); 
  20.  
  21. return $output;