diff --git a/rfo/rfo-informer.php b/rfo/rfo-informer.php new file mode 100644 index 0000000..1665189 --- /dev/null +++ b/rfo/rfo-informer.php @@ -0,0 +1,58 @@ + $parent_cat_id, + 'hide_empty' => false, +) ); + +// Собираем все ID: родительская + подкатегории +$category_ids = array( $parent_cat_id ); +foreach ( $subcats as $cat ) { + $category_ids[] = $cat->term_id; +} + +// Получаем 3 случайных поста из этих категорий +$params = array( + 'category__in' => $category_ids, + 'posts_per_page' => 3, + 'post_status' => 'publish', + 'orderby' => 'rand', + 'date_query' => array( + array( + 'after' => '1 month ago', + 'inclusive' => true, + ), + ), +); + + +$random_posts = get_posts( $params ); + +// Если нашли посты +if ( $random_posts ) { + // Выбираем случайный один из трёх + $post = $random_posts[ array_rand( $random_posts ) ]; + setup_postdata( $post ); + ?> + +
+ + + + diff --git a/sidebar-left.php b/sidebar-left.php index 787eb60..f07c5ae 100644 --- a/sidebar-left.php +++ b/sidebar-left.php @@ -35,11 +35,17 @@ if ( in_category('interviews') ) { - + + - + + + + + +