php – How to initialise WP_Query on the basis of a specific meta_value and continue iterating rest?

Question

I have a CPT with daily deals, I need to show these daily deals on my frontend as per today’s day.

For eg, if it is Thursday : The returning array should return Thursday, Friday, Saturday, Sunday, Monday, Tuesday, Wednesday.

For this to happen I have a meta_value on all posts namely Day which returns days in the following order:

$days = [
  1 => 'Monday',
  2 => 'Tuesday',
  3 => 'Wednesday',
  4 => 'Thursday',
  5 => 'Friday',
  6 => 'Saturday',
  7 => 'Sunday',
];

My current WP_Query is follows which returns data in ascending order according to date : Monday to Sunday

$args = array(
    'post_status' => 'publish',
    'post_type' => 'special',
    'meta_key' => 'day',
    'orderby' => 'day',
    'order' => 'ASC',
);

I want to construct a query such as I can assign a starting day and then continue the rest of the days.

Could anyone please help?

I tried adding comparing operators but they just remove the rest of the days as a whole.

0
Advait Nandeshwar 2 months 2022-11-26T13:15:48-05:00 0 Answers 0 views 0

Leave an answer

Browse
Browse