+3 votes
in Programming Languages by (59.8k 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

+1 vote
by (353k points)
selected by
Best answer

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

'orderby' => rand()


'orderby' => 'rand'