24 lines
777 B
PHP
24 lines
777 B
PHP
|
<?php
|
||
|
$posts_number = isset($args['posts_number']) ? $args['posts_number'] : 5;
|
||
|
$tag_slug = isset($args['tag_slug']) ? $args['tag_slug'] : '';
|
||
|
$block_header = isset($args['block_header']) ? $args['block_header'] : 'Сейчас читают';
|
||
|
|
||
|
?>
|
||
|
<h5 class="latest-articles__header"><?php echo $block_header; ?></h5>
|
||
|
<?php
|
||
|
echo '<ul class="latest-articles__list">';
|
||
|
global $post; // не обязательно
|
||
|
|
||
|
$myposts = get_posts( array(
|
||
|
'posts_per_page' => $posts_number,
|
||
|
'tag' => $tag_slug
|
||
|
) );
|
||
|
|
||
|
foreach( $myposts as $post ){
|
||
|
setup_postdata( $post );
|
||
|
echo get_template_part('blog-posts/blog-post-currently-reading');
|
||
|
}
|
||
|
|
||
|
wp_reset_postdata(); // сбрасываем переменную $post
|
||
|
echo '</ul>';
|
||
|
?>
|