How to check if page id is larger than a number


if (2030>1000 ) {
echo “display something”;
}elseif ( 1 > 2021 ) {
echo “display something more”;

@harshithareddy is this a mock?

Hi, @isitegate

You can try this:

<?php if(get_the_ID()>1000){?>
This page/post has an ID > 1000
<?php } ?>


<?php if (get_the_date("Y")<2021){?>
This page/post has been published before 2021
<?php } ?>

You can read the documentation on these functions here

Hope this helps,
Kind regards!

@vladytimy thanks a lot.
i tried looking at the documentations but can’t figure out if this is correct? ..
<?php if (get_the_date("l, F j, Y") < Friday, September 24, 2004){
<?php if (get_the_date("l, F j, Y") < 'Friday, September 24, 2004'){

or is there another way?

I’m not really sure how comparing dates in php works. (definetely not a php expert here) My first thought was that comparing two strings is not possible, but according to this
the 2nd code above code should work just fine.

The first one will result in an error – something like Friday is not definded/is not a constant. It’s a string so it needs ” ”

If the above comparation doesn’t work, try using strtotime().
Test it an see what works. 😀

I suggest making these changes in a child theme, so it doesn’t get reverted when your theme will update next time.

@vladytimy Thanks a lot, yes i’m using a child theme.
and now i have done it like this.
first checked the timestamp for the day, get_the_date(“U”)
<?php if (get_the_date(“U”) < 1611583484){ ?>
display something
<?php } ?>

Thanks again.

Source link