0

I am trying to display post count for a specific month, But something is wrong with my query because count is wrong. here I want to get post count for Aprel month. Can anyone help me please ? Thanks for your attention

$aprel = get_queried_object();

///////////////////////////////////////////////////
$aprelpost = array(
 'post_type' => 'MYCPT',
 'post_status'=>'publish',
    'tax_query' => array(
        'relation' => 'AND',
        array(
            'taxonomy' => 'sectors',
            'field'    => 'slug',
           'terms'    => $aprel->slug,
        ),
        
        'date_query' => array(
        'year'  => 2021,
        'month' => aprel
    )
   )
);
$aprelpost_query = new WP_Query ( $aprelpost );


$ap = $aprelpost_query ->post_count ;
echo ($ap);
0

here is correct answer if someone need

$aprel = get_queried_object();

///////////////////////////////////////////////////
$aprelpost = array(
 'post_type' => 'sikayet',
 'post_status'=>'publish',
    'tax_query' => array(
        'relation' => 'AND',
        array(
            'taxonomy' => 'sectors',
            'field'    => 'slug',
           'terms'    => $aprel->slug,
        ),  
   ),
      'date_query' => array(
        'year'  => 2021,
        'month' => 3
    )
);
$aprelpost_query = new WP_Query ( $aprelpost );


$ap = $aprelpost_query ->post_count ;
echo ($ap);

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.