'widget-blogsquare-tabs widget_tabs posts-thumbnail-widget',
'description' => __( 'Display popular & recent posts, comments and tags.', 'blogsquare' )
);
// Create the widget.
parent::__construct(
'blogsquare-tabs', // $this->id_base
__( '» Tabs', 'blogsquare' ), // $this->name
$widget_options // $this->widget_options
);
}
/**
* Outputs the widget based on the arguments input through the widget controls.
*
* @since 1.0.0
*/
function widget( $args, $instance ) {
extract( $args );
// Output the theme's $before_widget wrapper.
echo wp_kses_post( $before_widget );
?>
$instance['popular_num'],
'orderby' => 'comment_count',
'post_type' => 'post',
'date_query' => array(
//set date ranges with strings!
'after' => ''. $instance['day_limit'] . ' day ago',
'before' => 'today',
//allow exact matches to be returned
'inclusive' => true,
)
);
$i = 1;
$popular = new WP_Query( $args );
if ( $popular ) {
echo '
';
}
// Reset the query.
wp_reset_postdata();
?>
$instance['recent_num'],
'post_type' => 'post',
'post__not_in' => get_option( 'sticky_posts' ),
);
// The post query
$i = 1;
$recent = new WP_Query( $args );
if ( $recent ) {
echo '
';
}
// Reset the query.
wp_reset_postdata();
?>
(int) $instance['comments_num'], 'status' => 'approve', 'post_status' => 'publish' ) ); ?>
6,
'recent_num' => 6,
'comments_num' => 6,
'day_limit' => 10000,
'show_number' => true
);
$instance = wp_parse_args( (array) $instance, $defaults );
?>
id="get_field_id( 'show_number' ) ); ?>" name="get_field_name( 'show_number' ) ); ?>" />
$number,
'orderby' => 'comment_count',
'post_type' => 'post'
);
$i = 1;
$popular = new WP_Query( $args );
if ( $popular ) {
echo '';
}
// Reset the query.
wp_reset_postdata();
}
/**
* Recent Posts
*
* @since 1.0.0
*/
function blogsquare_latest_posts( $number = 6 ) {
// Posts query arguments.
$args = array(
'posts_per_page' => $number,
'post_type' => 'post',
'post__not_in' => get_option( 'sticky_posts' ),
);
// The post query
$i = 1;
$recent = new WP_Query( $args );
if ( $recent ) {
echo '';
}
// Reset the query.
wp_reset_postdata();
}