enter image description here

Can i use PHP code or something else to add "today day" like: Monday, Thuesday, Wednsday etc - inside the custom meta box?

Im trying to show today promotions, so it goes like "Today is monday, here you see monday offers"

Im using:

$today = date("l"); 

And try to make it

  $today = date("l");
 'post_type' => '',
 'posts_per_page' => 4,
 'meta_key' => 'eventdate',
  'meta_key' => 'thursday',
   'orderby' => 'meta_value',
   'order' => 'ASC',
    'meta_query' => array(
         'key' => 'eventdate',
       'meta-value' => $value,
       'value' => $today,
       'compare' => '>=',
       'type' => 'CHAR'// you can change it to datetime also

The code gets the day, and shows the stuff i have inside the thursday - meta box, but this way i would need to manually update the loop:

'meta_key' => 'thursday',

to friday, saturday etc.


'meta_key' => 'eventdate',

That i have to update also, every day manually, since i write the day of the week inside it.

I would like to add the day of the week like: <? echo date('l') ; ?> inside the custom meta box - is that possible?


I try hard to describle what im out after, so i edit my question like this:

'', 'posts_per_page' => 4, 'meta_key' => '$today', // I cud use the $today her so it grabs the costum post meta named: monday (correct?) 'orderby' => 'meta_value', 'order' => 'ASC', )); if (have_posts()) : while (have_posts()) : the_post(); ?>
    <?php $today = get_post_meta( get_the_ID(), '$today', true ); // If it is monday ( date("l") ) it would show the costum field "monday"

if ($today == '') { echo ''; } else { echo '

' . $today . '

'; } ?>

  • Can you please clarify "custom meta box"? Usually that refers to a box in the Editing screen, but this code appears to be more for front-end users. Do you mean a "widget" perhaps? – WebElaine Oct 19 '17 at 14:20
  • No, im very bad at all things about PHP - And my english sucks.... Try to make a template where i will show all "Todays offers".. If i make a post and add costum fields named "monday" "tuesday" etc - and then have the loop where it looks what the current day is ( date('l') and then it looks if get_post_meta( get_the_ID(), '###here i want to have the current day just like the date(l)###', true ); so it shows the meta :Monday - and next day it shows Tuesday etc... Im really sorry if i write like a mess, first time here :) – Tohelo Oct 19 '17 at 15:47

Your Answer

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

Browse other questions tagged or ask your own question.