10, 'kategorie' => '', 'layout' => 'grid', // grid | list 'badge' => '', ], $atts, 'server_news' ); $args = [ 'post_type' => 'mc_news', 'posts_per_page' => intval( $atts['anzahl'] ), 'post_status' => 'publish', 'meta_query' => [], 'tax_query' => [], ]; // Kategorie-Filter if ( ! empty( $atts['kategorie'] ) ) { $args['tax_query'][] = [ 'taxonomy' => 'mc_news_category', 'field' => 'slug', 'terms' => array_map( 'trim', explode( ',', $atts['kategorie'] ) ), ]; } // Angepinnte zuerst $pinned_args = $args; $pinned_args['meta_query'][] = [ 'key' => '_mcn_pinned', 'value' => '1' ]; $pinned_query = new WP_Query( $pinned_args ); $normal_args = $args; $normal_args['meta_query'][] = [ 'relation' => 'OR', [ 'key' => '_mcn_pinned', 'compare' => 'NOT EXISTS' ], [ 'key' => '_mcn_pinned', 'value' => '', 'compare' => '=' ], ]; $normal_query = new WP_Query( $normal_args ); ob_start(); ?>
'mc_news_category', 'hide_empty' => true ] ); foreach ( $cats as $cat ) { $icon = ! empty( $cat->description ) ? $cat->description . ' ' : ''; printf( '', esc_attr( $cat->slug ), $icon, esc_html( $cat->name ) ); } ?>
have_posts() ) { $query->the_post(); $post_id = get_the_ID(); $pinned = get_post_meta( $post_id, '_mcn_pinned', true ); $badge = get_post_meta( $post_id, '_mcn_badge', true ); $server_ip = get_post_meta( $post_id, '_mcn_server_ip', true ); $cats = get_the_terms( $post_id, 'mc_news_category' ); $cat_slugs = $cats ? implode( ' ', wp_list_pluck( $cats, 'slug' ) ) : ''; $cat_name = $cats ? $cats[0]->name : ''; $cat_icon = $cats ? $cats[0]->description : '📰'; ?>