Need to show 7 posts from actual date
I have specific category, in what I have a lot of posts. Every post starts from, for example 21 october 2019.
I have this code to show posts in the correct sequence:
class GoroskopController
{
static function get_data($parent_id, $number, $heading, $heading_color = 'dark')
{
$loop = new \WP_Query(GoroskopModule::loop_args($parent_id, $number));
if ($loop-have_posts()) :
echo 'div class="goroskop-block mb30"';
echo 'div class="block-heading-color-small -' . $heading_color . ' font-sans"' . $heading . '/div';
while ($loop-have_posts()) : $loop-the_post();
$this_date = self::this_gor(get_the_title());
include "templates/block.php";
endwhile;
wp_reset_query();
echo ($parent_id == 156) ? 'div class="view-more font-sans"a href="' . get_category_link($parent_id) . '"' . esc_html__('Смотреть все', 'grimple_core') . '/a/div' : '';
echo '/div';
endif;
}
static function now_date()
{
$m = [
'january' = '01',
'february' = '02',
'march' = '03',
'april' = '04',
'may' = '05',
'june' = '06',
'jule' = '07',
'august' = '08',
'september' = '09',
'october' = '10',
'november' = '11',
'december' = '12'
];
return $m;
}
static function this_gor($title)
{
$gor_date = explode(' ', $title);
$m = self::now_date();
$this_date = date('d.m.Y');
$day = (mb_strlen($gor_date[0],'UTF-8') == 1) ? '0' . $gor_date[0] : $gor_date[0];
$month = $gor_date[1];
$year = $gor_date[2];
foreach ($m as $key = $value) {
if ($month == $key)
$month = $value;
}
$sep = '.';
$gor_out_date = $day . $sep . $month . $sep . $year;
$this_gor = ($this_date == $gor_out_date) ? true : '';
return $this_gor;
}
}
and now I need to show only 7 posts from actual date.
I tried this
class GoroskopModule
{
static function loop_args($parent_id, $number)
{
$args = [
'cat' = $parent_id,
'showposts' = '7',
'orderby' = 'ID',
'order' = 'asc',
'date_query' = array('after' = date('d.m.Y', strtotime('-2 days')) )
];
return $args;
}
}
but it not work because I have a lot of posts what published in same day.
I need to show 7 posts from actual date calculated in first code. ty