Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

WordPress

Random Order to Posts

If you want your posts to display in random order, you can set the orderby property to rand.

$args = array(
        'post_type' => 'portfolio',
        'posts_per_page' => $numPosts,
        'orderby' => 'rand'
    );

    $query = new WP_Query( $args );

1 Answer

Carl Sergile
Carl Sergile
16,570 Points

This is the least of anyones problems. The issue most ppl like myself face is how to target specific content that gets displayed. For example you can't predict random post. So there for you have to pick random orders.....what I do and I dont know if its best practice is that I create categories for example about, contact, hobbies, and then place those wp queries at that sections that match their names(in pages). All this in hopes that clients find where to exactly place content. Maybe setup a chart or video of the site later....,what do you think?