Sunday, November 27, 2022
HomeWordPress Developmentphp - The best way to initialise WP_Query on the premise of...

php – The best way to initialise WP_Query on the premise of a selected meta_value and proceed iterating relaxation?


I’ve a CPT with each day offers, I want to point out these each day offers on my frontend as per at this time’s day.

For eg, whether it is Thursday : The returning array ought to return Thursday, Friday, Saturday, Sunday, Monday, Tuesday, Wednesday.

For this to occur I’ve a meta_value on all posts particularly Day which returns days within the following order:

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

My present WP_Query is follows which returns knowledge in ascending order in accordance with date : Monday to Sunday

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

I need to assemble a question comparable to I can assign a beginning day after which proceed the remainder of the times.

May anybody please assist?

I attempted including evaluating operators however they only take away the remainder of the times as a complete.

RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

- Advertisment -
Google search engine

Most Popular

Recent Comments