inve_blog

12, 'category’ => ”, 'featured’ => '1′, 'filters’ => '1′, ), $atts, 'inve_blog’ ); $paged = max( 1, get_query_var( 'paged’ ), get_query_var( 'page’ ) ); $args = array( 'post_type’ => 'post’, 'post_status’ => 'publish’, 'posts_per_page’ => (int) $a[’posts’], 'paged’ => $paged, 'ignore_sticky_posts’ => true, ); // filtr kategorii z shortcode’u lub z paska filtrów (?kat=slug) $active_cat = ”; if ( ! empty( $_GET[’kat’] ) ) { $active_cat = sanitize_title( wp_unslash( $_GET[’kat’] ) ); } elseif ( ! empty( $a[’category’] ) ) { $active_cat = sanitize_title( $a[’category’] ); } if ( $active_cat ) { $args[’category_name’] = $active_cat; } $q = new WP_Query( $args ); ob_start(); inve_blog_styles(); // ———- PASEK FILTRÓW ———- if ( '1′ === $a[’filters’] ) { $cats = get_categories( array( 'hide_empty’ => true ) ); if ( ! empty( $cats ) ) { $base = get_permalink(); echo ’’; } } if ( ! $q->have_posts() ) { echo ’

Brak wpisów w tej kategorii.

’; wp_reset_postdata(); return ob_get_clean(); } $i = 0; $show_featured = ( '1′ === $a[’featured’] && 1 === $paged ); echo ’
’; while ( $q->have_posts() ) { $q->the_post(); $i++; $cat_list = get_the_category(); $cat_name = ! empty( $cat_list ) ? $cat_list[0]->name : 'Blog’; $excerpt = wp_trim_words( get_the_excerpt(), 30, '…’ ); $mins = inve_reading_time( get_the_content() ); // ———- WPIS WYRÓŻNIONY (pierwszy, tylko na 1. stronie) ———- if ( $show_featured && 1 === $i ) { ?> Wpis wyróżniony ·

Czytaj dalej →
’; } // ———- KARTA WPISU ———- ?>

’; // .inve-grid // ———- PAGINACJA ———- $links = paginate_links( array( 'total’ => $q->max_num_pages, 'current’ => $paged, 'prev_text’ => '←’, 'next_text’ => '→’, 'type’ => 'array’, ) ); if ( $links ) { echo ’’; } echo ’
’; // .inve-grid-wrap wp_reset_postdata(); return ob_get_clean(); } add_shortcode( 'inve_blog’, 'inve_blog_shortcode’ ); /** * Szacowany czas czytania (200 słów/min). */ function inve_reading_time( $content ) { $words = str_word_count( wp_strip_all_tags( $content ) ); return max( 1, (int) ceil( $words / 200 ) ); } /** * Style — wypisywane raz na stronę. */ function inve_blog_styles() { static $done = false; if ( $done ) { return; } $done = true; ?>