+3 votes
in Programming Languages by (4.5k points)

I am using a Wordpress plugin for the random post. Today I checked my error log and found the following error: PHP Warning: Use of undefined constant rand - assumed 'rand'. I am using PHP 7.2.5. Here are the codes that I found by using the line number given in the error log.

    $args = array(
    'post__not_in' => $arr,
    'post_type' => 'post',
    'posts_per_page' => $noofpost,
    'orderby' => rand

1 Answer

0 votes
by (20k points)

Have you tried one of these two? Hopefully one of these two should work.

'orderby' => rand()

or 

'orderby' => 'rand'

...