filters – wp_query loop how to also display post second time with specific condition

Question

I filtered posts by period : from “current week”* , from * + 1 (following 2nd week), from * + 1 + 2 (following 3rd and 4th week) and from 1st day of current month * 12 month.

For the last one (the annual list) I want to display a post/an event for each month contained in its period. For example: an event runs from july 1 to September 7.
Currently, I display well the same post for the first (July) and last (September) month of its period but I can’t display this one in August inside Loop ! On the other hand I can display this one in August outside the loop only if the loop doesn’t contain none post .
It means that the conditions are good but the loop ignores it and I tried to understand why.

I use these arguments in wp_query.
Must I add some relation to correct my problem ?

$argslistyear = array(
    'post_type' => 'list_posts',
    'post_status' => 'publish',
    'posts_per_page'   => -1,
    'meta_key' =>'start_timestampevents',
    'orderby' => 'meta_value_num',
    'order' => 'ASC',
    'meta_query' => array(
       'relation' => 'OR',
       array(
          'key' => 'end_timestampevents',
          'value' => array($datestart,$dateend),
          'compare' => 'BETWEEN',
          'type' => 'NUMERIC'
       ),
       array(
          'key' => 'start_timestampevents',
          'value' => array($datestart,$dateend),
          'compare' => 'BETWEEN',
          'type' => 'NUMERIC'
       )
   )
);
$postsListYear =  new WP_Query($argslistyear);

0
imagIne 5 months 2023-07-08T06:45:02-05:00 0 Answers 0 views 0

Leave an answer

Browse
Browse