'widget_editors_choice', 'description' => esc_html__( 'Retrive Editors Choice.', 'blogood' ), ); $this->default_title = __( 'Top Posts & Pages', 'blogood' ); parent::__construct( 'blogood_editors_choice', esc_html__( 'TP : Editors Choice', 'blogood' ), $tp_widget_editors_choice ); } function form( $instance ) { $instance = wp_parse_args( (array) $instance, $this->defaults() ); if ( false === $instance['title'] ) { $instance['title'] = $this->default_title; } $title = stripslashes( $instance['title'] ); $count = isset( $instance['count'] ) ? (int) $instance['count'] : 10; if ( $count < 1 || 10 < $count ) { $count = 10; } $tp_category = isset( $instance['category'] ) ? absint( $instance['category'] ) : ''; ?>
defaults() ); $title = isset( $instance['title'] ) ? $instance['title'] : false; if ( false === $title ) { $title = $this->default_title; } /** This filter is documented in core/src/wp-includes/default-widgets.php */ $title = apply_filters( 'widget_title', $title ); $count = isset( $instance['count'] ) ? (int) $instance['count'] : false; if ( $count < 1 || 10 < $count ) { $count = 5; } $category = isset( $instance['category'] ) ? (int) $instance['category'] : 0; /** * Control the number of displayed posts. * * @module widgets * * @since 3.3.0 * * @param string $count Number of Posts displayed in the Top Posts widget. Default is 10. */ echo $args['before_widget']; if ( ! empty( $title ) ) { echo ""; } $post_args = array(); if( $category != '' ){ $post_args = array( 'numberposts' => $count, 'post_type' => 'post', 'category' => (array) $category, 'order' => 'ASC', ); } $posts = get_posts( $post_args ); ?>