'Zeigt die neuesten Server-News in der Sidebar.', ] ); } public function widget( $args, $instance ) { $title = apply_filters( 'widget_title', $instance['title'] ?? 'Server News' ); $anzahl = intval( $instance['anzahl'] ?? 3 ); echo $args['before_widget']; if ( $title ) echo $args['before_title'] . $title . $args['after_title']; $query = new WP_Query( [ 'post_type' => 'mc_news', 'posts_per_page' => $anzahl, 'post_status' => 'publish', ] ); if ( $query->have_posts() ) { echo '
'; wp_reset_postdata(); } else { echo 'Noch keine News vorhanden.
'; } echo $args['after_widget']; } public function form( $instance ) { $title = $instance['title'] ?? 'Server News'; $anzahl = $instance['anzahl'] ?? 3; ?>
sanitize_text_field( $new['title'] ), 'anzahl' => intval( $new['anzahl'] ), ]; } }