Question

<?php
    $rp = new WP_Query(array(
    'post_type' => array( 'post','videos','projects' ),
    'orderby' => 'date&order=DESC',
    'posts_per_page' => 4
    ));

    while ($rp->have_posts()) : $rp->the_post();
?>

I noticed that if I change date&order=DESC to rand, it makes no difference, meaning the posts don't show up in random order even after multiple refreshes. Is there something wrong w/ this code?

Was it helpful?

Solution

It should be this: WP_Query Order By Parameters

<?php
    $rp = new WP_Query(array(
    'post_type' => array( 'post','videos','projects' ),
    'orderby' => 'date',
    'order' => 'DESC',
    'posts_per_page' => 4
    ));

    while ($rp->have_posts()) : $rp->the_post();
?>
Licensed under: CC-BY-SA with attribution
Not affiliated with wordpress.stackexchange
scroll top