芝麻web文件管理V1.00
编辑当前文件:/home2/sdektunc/cepali.edu.mx/wp-content/themes/edufication/inc/widgets/latest-posts-widget.php
'widget_latest_post', 'description' => esc_html__( 'Retrive latest posts.', 'edufication' ), ); parent::__construct( 'edufication_latest_post', esc_html__( 'TP : Latest Posts', 'edufication' ), $tp_widget_popular_post ); } /** * Outputs the content of the widget * * @param array $args * @param array $instance */ public function widget( $args, $instance ) { // outputs the content of the widget if ( ! isset( $args['widget_id'] ) ) { $args['widget_id'] = $this->id; } $tp_title = ( ! empty( $instance['title'] ) ) ? ( $instance['title'] ) : ''; $tp_title = apply_filters( 'widget_title', $tp_title, $instance, $this->id_base ); $tp_number = isset( $instance['number'] ) ? absint( $instance['number'] ) : 3; echo $args['before_widget']; if ( ! empty( $tp_title ) ) { echo $args['before_title'] . esc_html( $tp_title ) . $args['after_title']; } $popular_args = array( 'post_type' => 'post', 'posts_per_page' => $tp_number, 'order' => 'DESC' ); echo '
'; $wp_query = get_posts( $popular_args ); foreach ( $wp_query as $post ) : ?>
ID ) ) : $image = get_the_post_thumbnail( $post->ID, $size = 'thumbnail', array( 'alt' => esc_attr( get_the_title( $post->ID ) ) ) ); echo $image; else : echo '
'; endif; ?>
post_title ); ?>
'; echo $args['after_widget']; } /** * Outputs the options form on admin * * @param array $instance The widget options */ public function form( $instance ) { $tp_title = isset( $instance['title'] ) ? ( $instance['title'] ) : esc_html__( 'Latest Posts', 'edufication' ); $tp_number = isset( $instance['number'] ) ? absint( $instance['number'] ) : 3; ?>